解決報錯:Access denied for user 'root'@'xxx' ,MySQL不容許從遠程訪問的方法 .

原文地址:傳送門html

 

例如,你想myuser使用mypassword從任何主機鏈接到mysql服務器的話。mysql

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH   PRIVILEGES;

若是你想容許用戶myuser從ip爲192.168.1.6的主機鏈接到mysql服務器,並使用mypassword做爲密碼sql

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH   PRIVILEGES;

若是你想容許用戶myuser從ip爲192.168.1.6的主機鏈接到mysql服務器的dk數據庫,並使用mypassword做爲密碼數據庫

GRANT ALL PRIVILEGES ON dk.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH   PRIVILEGES;

 

ps:阿里雲ECS就算設置host='%',容許從任何主機鏈接,可是仍然只能經過局域網ip訪問,很奇怪,還沒想通。服務器

相關文章
相關標籤/搜索