1.安裝MySQL
sudo? apt-get install mysql-server
2.登錄
mysql -u root -p? 后再輸入root密碼(若安裝時沒有設(shè)置密碼洼专,則需修改密碼)
3.為MySQL設(shè)置允許遠(yuǎn)程連接
進入MySQL中徐绑,執(zhí)行
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
再
FLUSH PRIVILEGES;
上述命令講創(chuàng)建username用戶允許訪問該數(shù)據(jù)庫,密碼為password
4.將root設(shè)置為可使用外網(wǎng)訪問;
USE mysql;
UPDARE user SET Host ='%' where User = 'root';
FLUSH PRIVILEGES;
5.如果不能連接,運行
sudo vi /etc/mysql/my.cnf
有可能在erc/mysql/mysql.conf.d目錄下
將bind-address =127.0.0.1這行注釋掉
6.對于服務(wù)器端,需要開啟3306端口