在云服務(wù)器上面搭建了MariaDb(MariaDB是MySQL源代碼的一個分支),但是遠(yuǎn)程鏈接不上。
首先,你要確保服務(wù)器安全組3306端口已經(jīng)開放。
在確保端口開放的情況下,如果出現(xiàn)錯誤代碼1130- Host xxx is not allowed to connect to this MariaDb server,說明是權(quán)限問題。
可能是你的帳號不允許從遠(yuǎn)程登陸,只能在localhost。這個時候只要在localhost的那臺電腦,登入MySQL后,更改 "mysql" 數(shù)據(jù)庫里的 "user" 表里的 "host" 項,從"localhost"改為"%"
mysql -u root -p
mysql>use mysql;
mysql>update user set host = '%' where user = 'root' and host='localhost';
mysql>select host, user from user;
然后重啟MySQL服務(wù)。