一、引言
- 平臺:阿里雲服務器平臺
- 系統:Ubuntu 16.04.1 LTS
二、mysql的安裝
首先需要更新庫
apt-get update
在線安裝mysql
apt-get install mysql-server
apt-get install mysql-client
apt-get install libmysqlclient-dev
測試mysql
mysql –V
service mysql start
service mysql stop
service mysql status
service mysql restart
允許遠程連接數據庫。編輯etc/mysql/mysql.conf.d/mysqld.cnf
,將bind-address
註釋掉。(不同版本目錄可能不同,也可能在/etc/mysql/my.cnf
中)
#bind-address = 127.0.0.1
如下圖所示:
登錄mysql
mysql -u root -p
設置遠程連接賬號及密碼,示例賬號爲root,密碼爲123456。
grant all on *.* to root@'%' identified by '123456' with grant option;
flush privileges;
如下圖所示:
重啓mysql或者重啓服務器
service mysql restart
shutdown -r now
三、阿里雲服務器配置
首先連接不上,先查看雲服務器上的安全組是否添加了對應的端口
阿里雲控制檯添加安全組規則
出入方向都需要定義
四、參考鏈接
https://blog.csdn.net/iywgqt/article/details/54694760
https://blog.csdn.net/qq_35038153/article/details/80723445
https://www.cnblogs.com/TimLiuDream/p/10067350.html