一.问题:远程无法连接服务器ubuntu上的mysql
二.解决方法:
1.ubuntu登陆msql,创建一个可以使远程连接的 MySQL 用户, 用户名:admin,密码:admin
mysql>GRANT ALL PRIVILEGES ON *.* TO admin@"%" IDENTIFIED BY 'admin' WITH GRANT OPTION;
2.修改mysql的配置文件 /etc/mysql/my.cnf
找到
# 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
将
bind-address = 127.0.0.1 这一行注释掉,即改为
#bind-address = 127.0.0.1
3.重启mysql
sudo /etc/init.d/mysql restart
这样就可以使用 用户名:admin,密码:admin 远程连接数据库了
测试方法:mysql -h ubuntu的ip -u admin -p admin