Ubuntu Server 下開啟遠端連接配接 MySQL 2008年11月12日 星期三 12:45
要通過遠端連接配接MySQL,需要做兩步: 第一步是要建立一個可以遠端連接配接的 MySQL 使用者 mysql> GRANT ALL PRIVILEGES ON username.* TO [email protected]"%" IDENTIFIED BY "password"; 第二步是要修改 mysql 的配置檔案 /etc/mysql/my.cnf $> sudo vi /etc/mysql/my.cnf 在舊版本中找到 skip-networking,把它注釋掉就可以了 #skip-networking 在新版本中: # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. bind-address = 127.0.0.1 bind-address = 127.0.0.1 這一行要注釋 #bind-address = 127.0.0.1 |
或者把允許通路的 ip 填上
#bind-address = 192.168.1.100
然後重新開機 MySQL
$> sudo /etc/init.d/mysql restart
* Starting MySQL database server mysqld
...done.
* Checking for corrupt, not cleanly closed and upgrade needing tables.
[email protected]:~$ sudo /etc/init.d/mysql start
* Starting MySQL database server mysqld
...done.
這樣就可以遠端通路 MySQL 了