数据库
首页 > 数据库> > MySQL新建普通用户和库并授予新用户对新库的所有权限

MySQL新建普通用户和库并授予新用户对新库的所有权限

作者:互联网

新建库

新建cmf和amon两个库,并指定默认字符集

mysql> create database cmf DEFAULT CHARACTER SET utf8;
Query OK, 1 row affected (0.00 sec)

mysql> create database amon DEFAULT CHARACTER SET utf8;
Query OK, 1 row affected (0.00 sec)

新建用户

新建cmf和amon两个用户并设置密码

mysql> create user 'cmf' identified by 'Admin@123';
Query OK, 0 rows affected (0.00 sec)

mysql> create user 'amon' identified by 'Admin@123';
Query OK, 0 rows affected (0.00 sec)

授权

mysql> grant all on cmf.* to 'cmf';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all on amon.* to 'amon';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

或者一条语句搞定新建用户和指定库授权问题

grant all on cmf.* TO 'cmf'@'%' IDENTIFIED BY 'Admin@123';
grant all on amon.* TO 'amon'@'%' IDENTIFIED BY 'Admin@123';
flush privileges;

 

 

 

 

 

 

  

标签:新库,affected,amon,cmf,MySQL,sec,mysql,OK,普通用户
来源: https://www.cnblogs.com/djlsunshine/p/12850447.html