1. 程式人生 > >設定mysql5.7遠端連線

設定mysql5.7遠端連線

在ubuntu14.04上安裝好mysql5.7之後,本地可以連線mysql伺服器。
遠端就不行。

註釋掉在/etc/mysql/mysql.conf.d/mysqld.cnf裡面的bind-address = 127.0.0.1

# By default we only accept connections from localhost
#bind-address   = 127.0.0.1

如果還有問題,如Access denied for user ‘root’@’ip地址’ (using password: YES)

mysql -uroot -p

輸入root使用者密碼,進入mysql伺服器命令列

use mysql;
Grant all on *.* to 'root'@'%' identified by 'root使用者的密碼' with grant option;
flush privileges;

然後用以下命令檢視哪些使用者和host可以訪問,%代表任意ip地址

select user,host from user;