mysql 命令行下添加用户

全栈 shanhuhai 1039℃

创建本地用户 test1 密码 123456 :

CREATE USER 'test1'@'localhost' IDENTIFIED BY '132456';

创建任意主机可登录的用户 test2 密码 123456 :

CREATE USER 'test2'@'%' IDENTIFIED BY '123456';

授权用户 test1 所用权限(相当于root):

GRANT ALL ON *.* TO 'tset1'@'%';

*如果出现类似:Access denied for user ‘root’@’localhost’ while attempting to grant privileges. 的错误
则执行 mysql_upgrade 然后重新授权*

查看权限 :

 SELECT * FROM mysql.user WHERE User='test1' and Host='%'\G

刷新权限 :

flush privileges;

修改用户密码:

set password for test1@"localhost"=password('123456');
flush privileges;

转载请注明:大后端 » mysql 命令行下添加用户

喜欢 (1)or分享 (0)