MySQL8.0給root使用者賦予遠端連線許可權(Windows)
阿新 • • 發佈:2021-01-16
問題
直接使用grant all privileges on *.* to 'root'@'%' with grant option;
給root使用者賦予可遠端連線許可權時報錯
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY '123456' WITH GRANT OPTION' at line 1
解決
# 選中mysql資料庫
use mysql;
# 修改庫中user表中,user使用者的host=%(任意連線)
update user set host='%' where user ='root';
# 重新載入許可權表
flush privileges;
# 給root使用者賦予遠端連線許可權
grant all privileges on *.* to 'root'@'%' with grant option;
測試, 成功。