MySQL更新到8.0以上版本后,在創建連接遠程的用戶的時候和之前5.x的版本有了很大的不同,不能使用原來同時創建用戶和授權的命令。
以下是記錄的MySQL8.0創建用戶並授權的命令:
- 查看用戶表:
user mysql;
select host,user,authentication_string,plugin from user;
- 創建可遠程連接用戶
mysql>create user dongxt@'%' identified by 'password';
- 給用戶授權
mysql>grant all privileges on *.* to dongxt@'%' with grant option;
- 刷新權限
mysql>flush privileges;
- 修改遠程連接用戶的加密規則
mysql>alter user dongxt@'%' identified with mysql_native_password by 'password';