一、安装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

图有‘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 新密码

三、配置远程访问
- 编辑配置文件,注释掉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数据库。