mysql 8.0.12 用户权限命令

示例:用户名mayiic_dev 密码mayiic123

1.创建用户:

create user 'mayiic_dev'@'%' identified by 'mayiic123';

2.修改加密规则:

alter user 'mayiic_dev'@'%' identified with mysql_native_password by 'mayiic123';

3.赋予insert,select,update权限和全部权限,“test01”为数据库,“mayiic_dev”为用户:

grant insert,select,update on test01.* to 'mayiic_dev'@'%';
grant all privileges on test01.* to 'mayiic_dev'@'%';

4.刷新权限:

flush privileges;

5.查看权限:

show grants for mayiic_dev;

6.删除用户:

drop user mayiic_dev@'%';

7.用客户软件如navicat连接mysql报错“caching-sha2-password”,原因是mysql8.0采用了新的更安全的验证方式,修改配置文件

vim /etc/my.cnf

加入内容:default_authentication_plugin=mysql_native_password


mysql 8.0.12 用户权限命令_第1张图片
image.png

*注意:如果连接不上,查看防火墙firewalld或者iptables是否关闭,开启的话是否开放对应mysql的端口,云服务器的话查看安全组是否开放对应的mysql端口

你可能感兴趣的:(mysql 8.0.12 用户权限命令)