第一步:
首先鏈接本機的mysql(用ssh登錄終端,輸入如下命令):
mysql -uroot -p輸入密碼登陸進去後,輸入如下的語句,執行。
grant all privileges on *.* to ‘user‘@’%‘ identified by ‘password‘ with grant option;其中,user是用戶名,mysql默認的是root ,password是密碼自己設置 。%表示任意主機。這樣就允許遠程任意一臺主機訪問了。
第二步:
尋找bind-address屬性。這個屬性一般在 /etc/mysql/my.conf 要不然就在 /etc/mysql/mysql.conf.d/mysqld.cnf
在這個文件裏尋找bind-address屬性
然後在bing-address前面加上#
結果爲#bind-address,這樣你就可以訪問了。