mysql 给其他用户赋值 数据库权限

登陆root或者管理员用户

#test 数据库用户名
#testpassword 数据库密码
#创建允许远程访问的用户 create user test@
'%' identified by 'testpassword';
#执行成功之后刷新用户权限
flush privileges;

# 允许root用户远程连接
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

flush privileges;
 

执行

#admin_v6 为数据库名称
grant all privileges on admin_v6.* to "test"@"%" identified by "testpassword" with grant option;

#执行成功之后刷新用户权限
flush privileges;

 

 

允许mysql用户远程访问

注:只支持mysql 8.0之前的版本

grant all on *.* to test@'%' identified by '你的密码' with grant option;
flush privileges;

%表示允许任何ip地址

账户如果不存在的话会创建

mysql 8.0之后的版本

grant all privileges on *.* to test@'%' with grant option;

#使用navicat连接mysql 8.0 密码加密规则问题,错误码【1251】
ALTER USER 'test'@'%' IDENTIFIED WITH mysql_native_password BY '你的密码';
  

 

 

删除用户

drop user 'test'@'%';

 

查询所有用户

SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;

 

posted @ 2020-05-19 21:26  php的自我修养  阅读(1672)  评论(0编辑  收藏  举报