当前位置:Gxlcms > 数据库问题 > Mysql命令行新增用户

Mysql命令行新增用户

时间:2021-07-01 10:21:17 帮助过:2人阅读

mysql -uroot -p

登录mysql

use mysql;

创建用户:
create user ‘test123‘@‘localhost‘ identified by ‘12345‘;
这里的test123表示User,localhost表示Host,12345表示authentication_string(密码)

授权:
grant all privileges on *.* to ‘test123‘@‘localhost‘;
这里的*.* 可以改成 testdb.*,testdb 表示具体的某一个库,testdb.*表示 testdb库的所有表
这里的all privileges表示所有权限,权限分为:select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file等14个权限
所以这里也可以这样授权:
grant select,insert,update,delete on *.* to ‘test123‘@‘localhost‘;

刷新:
flush privileges;

做完增删改之后都要记得刷新授权

 

Mysql命令行新增用户

标签:

人气教程排行