Mysql创建用户并授权远程访问

进入控制台,登录mysql:mysql -u root -q  ,输入密码后,进入mysql命令行

创建数据库:create database abc; //以创建abc为例

创建用户:create user user01@'localhost' identified by 'password';    // 本地访问

                  create user user02@'%' identified by 'password';   // 远程访问
授权,给user02用户 赋予 abc 库所有操作DML  DDL:grant all privileges on abc.* to user02;

如果只开通所有库 查询权限,命令为: grant select on *.* to 'user02'@'%' identified by 'anotherpassword';

 

posted @ 2021-04-01 21:35  JimmyShan  阅读(482)  评论(0编辑  收藏  举报