首先防火墙开放3306
编辑
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
注释 bind-address = 127.0.0.1 添加 skip-name-resolve
允许非本地登陆
mysql -u root -p
mysql>use mysql;
查看root账号的登录权限
mysql>select host, user from user;
修改登录权限
mysql>update user set host = '%' where user = 'root';
刷新,生效,最后一步,至关重要
mysql>flush privileges;
注意,以上修改以后,会导致 mysql -h localhost -u root 无法登陆了,所以统一账号加密码登陆方式(mysql -u root -p)
接下来:继续参考https://stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost
$ sudo mysql -u root # I had to use "sudo" since is new installation
mysql> USE mysql;
mysql> SELECT User, Host, plugin FROM mysql.user;
+------------------+-----------------------+
| User | plugin |
+------------------+-----------------------+
| root | auth_socket |
| mysql.sys | mysql_native_password |
| debian-sys-maint | mysql_native_password |
+------------------+-----------------------+
修改方法一:
$ sudo mysql -u root # I had to use "sudo" since is new installation
mysql> USE mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> exit;
$ service mysql restart
这样,就可以通过Navicat直接通过3306远程登陆了