MYSQL8 常用操作

  • 开启root账号远程访问

  方法1

mysql> CREATE USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123123'; //修改密码认证方式为mysql_native_password
mysql> GRANT ALL ON *.* TO 'root'@'%';

  方法2

mysql> CREATE USER 'root'@'%' IDENTIFIED BY '123123'; //默认的密码认证插件 caching_sha2_password
mysql> GRANT ALL ON *.* TO 'root'@'%';
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123123';
  • 创建数据库
mysql> CREATE database IF NOT EXISTS meeting;
  • 创建账号
mysql> CREATE USER meeting IDENTIFIED BY 'pass123';
  • 授权
# 下面这个缺少 create index 权限、select 权限等,应该赋权限 ALL
mysql>
GRANT EXECUTE,SELECT,INSERT,UPDATE,DELETE,DROP,CREATE,DROP,ALTER ON meeting.* TO 'meeting'@'%' WITH GRANT OPTION; mysql> FLUSH PRIVILEGES;
  • 修改密码
mysql> ALTER USER 'meeting'@'%' identified with mysql_native_password by 'pass456';
  • 特别注意
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123';
ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'localhost'
如遇上以上问题请使用update语句先清空authentication_string字段,然后再修改密码即可

mysql> UPDATE user SET authentication_string='' WHERE USER='root'; 
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';

 

最新使用的创建用户及授权 
CREATE USER hrofferuser IDENTIFIED BY '123456';

flush PRIVILEGES

GRANT ALL ON `hr-offer`.* TO 'offeruser'@'%' WITH GRANT OPTION;

revoke all on eic.* from 'offeruser'@'%'; 

 

posted on 2019-07-01 18:50  doraman  阅读(544)  评论(0编辑  收藏  举报