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';
- 特别注意
CREATE USER hrofferuser IDENTIFIED BY '123456'; flush PRIVILEGES GRANT ALL ON `hr-offer`.* TO 'offeruser'@'%' WITH GRANT OPTION; revoke all on eic.* from 'offeruser'@'%';