mysql开启远程连接

出发点 由于桥梁项目需要用到MySQL数据库,想着自己实验室服务器的MySQL已经装好了,就安装Navicat准备远程连接,通过shell进行连接发现运行正常

mysql -u root -p

【mysql开启远程连接】但是使用Navicat连接时出现错误,拒绝连接,于是想到可能MySQL不允许远程登录
开启远程IP登录许可
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

bind-address = 127.0.0.1前面加上#
lc-messages-dir = /usr/share/mysql skip-external-locking # # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. # bind-address= 127.0.0.1

之后重启MySQL即可
/etc/init.d/mysql restart

添加用户 开启远程登录之后发现出现了新的错误:... is not allowed to connect to this MySql server
于是通过shell登录MySQL,依次执行以下命令
use mysql; update user set host=’%’ where user=’root’;

遂远程连接成功

    推荐阅读