1.安裝mysql:
Debian: /# apt-get install mysql-server
mysql Ver 14.14 Distrib 5.5.40, for debian-linux-gnu (x86_64) using readline 6.2
2.賦予遠程數(shù)據(jù)庫訪問權(quán)限:
mysql > GRANT ALL ON *.* TO 'client'@'%' IDENTIFIED BY 'your_client_password' WITH GRANT OPTION;
這句話指允許任何ip的client賬戶用密碼your_client_password來遠程訪問該服務(wù)器上的mysql
3.修改/etc/mysql/my.conf
修改前我們啟動mysql后發(fā)現(xiàn)
Debian: /# netstat -an |grep 3306
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
這里的 Local Address為127.0.0.1:3306說明mysql的當(dāng)前只能本機訪問,所以我們在/etc/mysql/my.conf中將如下字段注釋掉:

my.conf
mysql重啟后再查看3306端口localAddress改為了0.0.0.0,這時mysql就可以被遠程訪問了
Debian: /# netstat -an |grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN