美文网首页
MySQL添加新用户、为用户创建数据库、为新用户分配权限

MySQL添加新用户、为用户创建数据库、为新用户分配权限

作者: 付存 | 来源:发表于2018-09-10 13:40 被阅读0次

登录MySQL 
mysql -u root -p  

创建用户

允许本地 IP 访问 localhost, 127.0.0.1 

create user 'test'@'localhost' identified by '123456';

允许外网 IP 访问

create user 'test'@'%' identified by '123456';

刷新授权

flush privileges;

创建数据库

create database test DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

分配权限

授予用户通过外网IP对于该数据库的全部权限 

grant all privileges on `testdb`.* to 'test'@'%' identified by '123456';

授予用户在本地服务器对该数据库的全部权限

grant all privileges on `testdb`.* to 'test'@'localhost' identified by '123456';

授予授予用户通过外网IP对于该数据库的只读权限

grant select privileges on `testdb`.* to 'test'@'%' identified by '123456';

刷新授权

flush privileges;

 

 

相关文章

网友评论

      本文标题:MySQL添加新用户、为用户创建数据库、为新用户分配权限

      本文链接:https://www.haomeiwen.com/subject/vzlsgftx.html