简体   繁体   English

远程连接Mysql Ubuntu-绑定地址失败

[英]Remote Connections Mysql Ubuntu - bind address failed

I am trying to configure my server to allow remote connections. 我正在尝试将服务器配置为允许远程连接。

From what I understand I need to uncomment bind-address 127.0.0.1 in the my.cnf file, then restart mysql. 据我了解,我需要取消注释my.cnf文件中的绑定地址127.0.0.1,然后重新启动mysql。

That hasn't worked. 那没有用。

I have also tried changing it to bind-address 0.0.0.0. 我也尝试将其更改为绑定地址0.0.0.0。

That hasn't worked either. 那也没有用。

When I try to remotely connect using SQLpro, I get the following error: 当我尝试使用SQLpro进行远程连接时,出现以下错误:

MySQL said: Can't connect to MySQL server on '54.444.33.4' (4) MySQL说:无法连接到“ 54.444.33.4”上的MySQL服务器(4)

Can anybody offer any other solutions? 有人可以提供其他解决方案吗?

Thanks. 谢谢。

First of all; 首先; to be able to remotely access your database remotely from another computer etc. You have to give an IP which is either Private or Public and do configurations according to that. 为了能够从另一台计算机等远程访问数据库。您必须提供一个IP,该IP可以是Private或Public,并根据该IP进行配置。 In this case, I'll tell you how to do it in LAN : 在这种情况下,我将告诉您如何在LAN中进行操作:

Do a full fresh installation of MySQL with below commands : 使用以下命令进行MySQL的全新安装:

sudo apt-get update
sudo apt-get mysql-server
sudo mysql_install_db
sudo mysql_secure_installation

At the last command, determine a password and press "ENTER" to all other questions it asks during installation to make them default settings. 在最后一个命令中,确定一个密码,然后对安装过程中询问的所有其他问题按“ ENTER”将其设置为默认设置。

Go and open terminal and type the command below : 打开终端,然后输入以下命令:

ifconfig

You'll see the Private IP that the router gives you from here, should be something like ex : 192.168.1.10 您将看到路由器从此处提供给您的私有IP,应该类似于ex:192.168.1.10

After you acquire the IP, open /etc/mysql/mysql.cnf and change the bind adress to the IP you've acquired, in this case : 获取IP后,打开/etc/mysql/mysql.cnf并将绑定地址更改为您获取的IP,在这种情况下:

bind-address= 192.168.1.10

Restart the server via, 通过以下方式重新启动服务器:

sudo service mysql restart

After this case, I'll give you some tips for Security. 在这种情况下,我将为您提供一些安全提示。 Never allow your root user remotely accessible, that is just unsecure. 绝对不要让您的root用户可以远程访问,那是不安全的。 Type the below commands to make another admin user access the Server from anywhere : 键入以下命令,以使另一个管理员用户可以从任何地方访问服务器:

mysql -u root -p

(It will ask you password of mysql root user, type it in and get into mysql line) (它会询问您mysql root用户的密码,输入该密码并进入mysql行)

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
CREATE USER 'username'@'IP ADDRESS' IDENTIFIED BY 'password';

I usually give SELECT, UPDATE, DELETE, INSERT to a remote user, but you can give all privileges as well, I'll give you commands for both : 我通常将SELECT,UPDATE,DELETE,INSERT授予远程用户,但是您也可以赋予所有特权,我将为这两个都提供命令:

GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
GRANT SELECT,INSERT,DELETE,UPDATE ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit;

After all these, restart the service once more and you can connect to your MYSQL Server from any computer connected to the network. 完成所有这些操作后,再次重新启动服务,您可以从连接到网络的任何计算机连接到MYSQL Server。 Cheers! 干杯!

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

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