mysql远程访问
增加可远程访问的mysql账户
-
登陆mysql客户端
mysql -uroot -p[密码]
-
创建可远程的MySQL账号
grant 权限列表 on 数据库 to '用户名'@'%' identified by '密码';
注意是:‘用户名’@’%’,其中“%”表示此账户可以使用任何ip的主机登录访问此数据库
-
修改配置文件
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
-
查找到"bind-address = 127.0.0.1"并将该句注释
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
注释后为
# localhost which is more compatible and is not less secure.
# bind-address = 127.0.0.1
- 重启MySQL服务
sudo service mysql restart
- 测试是否可以连接
telnet [ip] [3306]
参考文献
Can’t Connect to MySQL Server Remotely on Ubuntu | DevAnswers.co