当前位置:Gxlcms > 数据库问题 > mysql5.7新增加用户和授权

mysql5.7新增加用户和授权

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

myuser@localhost IDENTIFIED BY mypassword; #本地登录 CREATE USER myuser@% IDENTIFIED BY mypassword; #远程登录 quit; mysql -u myuser -p #测试是否创建成功 # 权限修改 grant 权限 on 数据库.* to 用户名@登录主机 identified by 密码; flush privileges; # 刷新系统权限表

service mysql restart

拿test作为示例:

 1 # 进入mysql
 2 mysql -u root -p
 3 # 本地访问账户
 4 CREATE USER test@localhost IDENTIFIED BY ln122920;
 5 # 远程访问
 6 CREATE USER test@% IDENTIFIED BY ln122920;
 7 # 本地全部授权,授权test用户拥有testDB数据库的所有权限
 8 grant all privileges on testDB.* to test@localhost identified by ln122920;
 9 # 远程全部授权,授权test用户拥有testDB数据库的所有权限
10 grant all privileges on testDB.* to test@% identified by ln122920;
11 # 刷新权限
12 flush privileges;

如果你只需要部分权限,则:

grant select,update on testDB.* to test@localhost identified by ln122920; 
flush privileges;    # 刷新权限

 最后重启一下:service mysql restart

mysql5.7新增加用户和授权

标签:bsp   round   for   col   测试   权限   art   localhost   设置   

人气教程排行