简体   繁体   English

允许远程访问ubuntu服务器上的mysql数据库

[英]Allow remote access to mysql database on ubuntu server

I have my database on one ubuntu server and i want to use the same database on that server as well as on other ubuntu server.I have tried all the possible tutorials available for allow remote access but it's not working. 我在一个ubuntu服务器上有我的数据库,我想在该服务器以及其他ubuntu服务器上使用相同的数据库。我已经尝试了所有可用的教程,允许远程访问,但它不起作用。 I am getting the error below when i try to access the database from local machine 当我尝试从本地计算机访问数据库时,我收到以下错误

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. 连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机无法响应。

I have set bind-address=0.0.0.0 in my.cnf file and also create new user by following commands: 我在my.cnf文件中设置了bind-address = 0.0.0.0,并通过以下命令创建新用户:

mysql –u root -p
GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

Is there any solution which can solve this issue? 有没有解决方案可以解决这个问题?

make sure firewall isn't blocking your request. 确保防火墙没有阻止您的请求。 disable firewall first sudo systemctl stop firewalld try connecting if it works then add mysql to firewall 禁用防火墙首先sudo systemctl停止firewalld尝试连接,如果它的工作原理,然后将mysql添加到防火墙

first start firewall again 首先再启动防火墙

sudo systemctl start firewalld sudo systemctl启动firewalld

lookup for your zone 查找您的区域

sudo firewall-cmd --get-active-zone sudo firewall-cmd --get-active-zone

let's say it answer "work" 让我们说它回答“工作”

sudo firewall-cmd --permanent --zone=work --add-service=mysql sudo firewall-cmd --permanent --zone = work --add-service = mysql

at last try connecting again 最后再次尝试连接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM