一、安裝MySQL
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install libmysqlclient-dev
二、更改默認密碼
sudo cat /etc/mysql/debian.cnf
![image.png image.png](http://static.javashuo.com/static/loading.gif)
圖有‘user=debian-sys-maint’,即爲自動配置的默認用戶;‘password=ol9uVJAxu9L1AzOa’,即爲自動配置的密碼。
mysql -u debian-sys-maint -p // 用戶名以本身的配置文件爲準
提示輸入密碼,這裏要輸入的就是上一步的‘password=ol9uVJAxu9L1AzOa’(密碼以本身的配置文件爲準)。
use mysql;
// 下一行,密碼改成了yourpassword,能夠設置成其餘的
update mysql.user set authentication_string=password('yourpassword') where user='root' and Host ='localhost';
update user set plugin="mysql_native_password";
flush privileges;
quit;
sudo service mysql restart mysql -u root -p 新密碼
![image.png image.png](http://static.javashuo.com/static/loading.gif)
三、配置遠程訪問
- 編輯配置文件,註釋掉bind-address = 127.0.0.1:
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
grant all on *.* to root@'%' identified by '你的密碼' with grant option; flush privileges;
四、重啓服務
sudo service mysql restart
如今可在Navicat軟件上遠程鏈接MySQL數據庫。