远程连接ubuntu中mysql的数据库

1、配置防火墙,打开3306端口

sudo ufw status
sudo ufw allow 3306
netstat -an | grep 3306

2、此时连接仍然失败,报错

ERROR 1130 (HY000): Host '192.168.116.129' is not allowed to connect to this MySQL server

原因是mysql只允许本主机访问,这时更改配置,进入ubuntu下mysql,输入下面命令

use mysql
select host from user where user = 'root';
update user set host='%' where user = 'root';
flush privileges;

连接成功

参考:
https://www.cnblogs.com/code4app/p/7355525.html

猜你喜欢

转载自blog.csdn.net/qq_29579431/article/details/89381308