MySQL用户管理(创建用户,查看用户,删除用户,修改密码)
mysql> create user lhd@'172.16.1.%' identified by '123';
Query OK, 0 rows affected (0.02 sec)
mysql> select user,host from mysql.user;
+--------+------------------------+
| user | host |
+--------+------------------------+
| qiudao | 10.0.0.0/24 |
| lhd | 10.0.0.0/255.255.255.0 |
| lhd | 172.16.1.% |
| root | localhost |
+--------+------------------------+
4 rows in set (0.00 sec)
mysql> drop user qiudao@'10.0.0.0/24';
Query OK, 0 rows affected (0.00 sec)
#1.方式一:命令行修改密码
[root@db02 /service]# mysqladmin -uroot -p password
Enter password: 123456
New password: 123
Confirm new password: 123
#2.方式二:授权的方式修改密码
mysql> grant all on *.* to lhd@'10.0.0.0/255.255.255.0' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
#3.方式三:更新数据库密码
mysql> update mysql.user set password=PASSWORD('123456') where user='lhd' and host='172.16.1.%';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
#4.方式四:直接设置密码
mysql> set password=PASSWORD('123456');
Query OK, 0 rows affected (0.00 sec)
本文来自博客园,作者:六月OvO,转载请注明原文链接:https://www.cnblogs.com/chenlifan/p/13874812.html