当前位置:网站首页>第15章 mysql用户管理
第15章 mysql用户管理
2022-07-26 21:16:00 【发狂的蜗牛】
第一节:登录和推出mysql服务器
启动mysql服务器后,可以利用mysql命令来登录mysql服务器,命令如下:
mysql -h hostname|hostip -P port -u username -p DatabaseName -e "sql语句"
这个命令的几个参数如下:
-h 参数后面接主机名称或者主机IP,hostname是主机名称,hostip是主机IP
-P 参数后面接Mysql服务的端口,通过该参数登录到Mysql指定端口。mysql服务的默认端口是3306,不适用该参数时自动连接到3306端口,port为连接的端口号。
-u参数后面接用户名。username是用户名。
-p 参数会提示用户输入密码(这个语句回车后会有提示输入密码窗口)
-e 参数后面可以直接接mysql语句。登录mysql服务器后立即可执行这个SQL语句,然后退出mysql服务器。
下面自己先来个简单点的:
在win命令行中输入:
mysql -h localhost -uroot -p
下面把-h后面换成主机ip,如下:

下面自己再来一个:


mysql执行:
mysql -h127.0.0.1 -uroot -P 3306 mysql -e "select * from db" -p 
可以看出,如果制定了-e选项,那么登录数据库后立即运行这个语句,运行完毕后就立刻推出了mysql服务器。
第二节:mysql新建普通用户
1.用CREATE USER来创建用户:
mysql 用CREATE USER来创建新用户(当然必须有CREATE USER权限).CREATE USER的基本语法结构如下:
![]()
例如:执行下面的语句可以创建一个用户:user1,密码是 user1
CREATE USER 'user1'@'localhost' identified by 'user1';执行完上述语句后,试着登录:

结果显示登录成功。
2.试着用insert命令来创建用户:
边栏推荐
- It is said that Samsung obtained EUV photoresist from Belgium
- Vi和Vim文本编辑器
- js验证复杂密码
- imshow()函数后面如果不加waitKey()函数就不显示
- Summer vacation daily question week 7:7.18 - 7.24
- [mysql]substr usage - query the value of specific digits of a field in the table
- Go -- go language naming specification
- Oppo self-developed large-scale knowledge map and its application in digital intelligence engineering
- Jd.com: how does redis realize inventory deduction? How to prevent goods from being oversold?
- 一篇让小百彻底搞懂性能调优
猜你喜欢

imshow()函数后面如果不加waitKey()函数就不显示

Task04 | classification analysis

Let Xiaobai thoroughly understand performance tuning

Altium designer 22 modify the layer properties of the selected component

Summer vacation daily question week 7:7.18 - 7.24

I successfully landed the automatic testing post, with a maximum monthly salary of 15.4k. I'm great~

彻底搞通服务发现的原理和实现

matlab 短时自相关实现

Altium designer 22 Chinese character garbled

Just one dependency to give swagger a new skin, which is simple and cool
随机推荐
FreeRTOS personal notes - Events
Go----Go语言中的变量使用方法
Matlab pitch period estimation post-processing
彻底搞通服务发现的原理和实现
easyui的combobox默认选中第一个选项
Difference between D and C
1 - "pytorch deep learning practice" - linear model
吃透负载均衡
d和c的符区别
Can you use redis? Then come and learn about redis protocol
C# 数据类型_摘自菜鸟教程
45、实例分割的labelme数据集转coco数据集以及coco数据集转labelme数据集
Resume in 2022 is dead in the sea. Don't vote. Software testing positions are saturated
逻辑漏洞----任意账号注册
A new technical director asked me to do an IP territorial function~
Implementation of MATLAB short-time autocorrelation
matlab 画短时平均幅度谱
Vi和Vim文本编辑器
虾皮shopee根据关键词取商品列表 API
Li Kou daily question - day 43 -168. Name of Excel table column