示例:用户名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