当前位置:Gxlcms > 数据库问题 > MySQL 新建用户,为用户授权,指定用户访问数据库

MySQL 新建用户,为用户授权,指定用户访问数据库

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

test@* identified by 123456;

#test:用户名,*:所有ip地址,123456:密码

3.创建数据库
CREATE DATABASE test_db  DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
4.为新用户分配权限
grant all privileges on `test_db`.* to test@% identified by 123456; 
#授权给用户test,数据库test_db相关的所有权限,并且该用户test在所有网络IP上都有权限,%是指没有网络限制 5.刷新权限
flush privileges;

 

6. 修改用户的IP访问权限

use mysql;
update user set host = % where user =test;

 

MySQL 新建用户,为用户授权,指定用户访问数据库

标签:登录   ges   plain   sql   general   color   har   ant   bsp   

人气教程排行