远程连接 Mysql Ubuntu - 绑定地址失败 [英] Remote Connections Mysql Ubuntu - bind address failed

查看:50
本文介绍了远程连接 Mysql Ubuntu - 绑定地址失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试配置我的服务器以允许远程连接.

I am trying to configure my server to allow remote connections.

据我所知,我需要在 my.cnf 文件中取消注释 bind-address 127.0.0.1,然后重新启动 mysql.

From what I understand I need to uncomment bind-address 127.0.0.1 in the my.cnf file, then restart mysql.

那没有用.

我也尝试将其更改为绑定地址 0.0.0.0.

I have also tried changing it to bind-address 0.0.0.0.

那也没有用.

当我尝试使用 SQLpro 进行远程连接时,出现以下错误:

When I try to remotely connect using SQLpro, I get the following error:

MySQL 说:无法连接到 '54.444.33.4' 上的 MySQL 服务器 (4)

MySQL said: Can't connect to MySQL server on '54.444.33.4' (4)

谁能提供任何其他解决方案?

Can anybody offer any other solutions?

谢谢.

推荐答案

首先;能够从另一台计算机等远程远程访问您的数据库.您必须提供一个私有或公共IP,并根据它进行配置.在这种情况下,我会告诉您如何在局域网中进行操作:

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. In this case, I'll tell you how to do it in LAN :

使用以下命令完全全新安装 MySQL:

Do a full fresh installation of MySQL with below commands :

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

在最后一个命令中,确定密码,然后按ENTER"键回答安装过程中询问的所有其他问题,使它们成为默认设置.

At the last command, determine a password and press "ENTER" to all other questions it asks during installation to make them default settings.

打开终端并输入以下命令:

Go and open terminal and type the command below :

ifconfig

你会从这里看到路由器给你的私有 IP,应该是这样的:192.168.1.10

You'll see the Private IP that the router gives you from here, should be something like ex : 192.168.1.10

获取IP后,打开/etc/mysql/mysql.cnf,修改绑定地址为获取的IP,本例:

After you acquire the IP, open /etc/mysql/mysql.cnf and change the bind adress to the IP you've acquired, in this case :

bind-address= 192.168.1.10

重启服务器,

sudo service mysql restart

在这个案例之后,我会给你一些关于安全的提示.永远不要让您的 root 用户远程访问,那是不安全的.键入以下命令让另一个管理员用户从任何地方访问服务器:

After this case, I'll give you some tips for Security. Never allow your root user remotely accessible, that is just unsecure. Type the below commands to make another admin user access the Server from anywhere :

mysql -u root -p

(它会问你mysql root用户的密码,输入后进入mysql行)

(It will ask you password of mysql root user, type it in and get into mysql line)

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

我通常将 SELECT、UPDATE、DELETE、INSERT 授予远程用户,但您也可以授予所有权限,我将为您提供两者的命令:

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 :

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;

完成所有这些之后,再次重新启动该服务,您就可以从任何连接到网络的计算机连接到您的 MYSQL Server.干杯!

After all these, restart the service once more and you can connect to your MYSQL Server from any computer connected to the network. Cheers!

这篇关于远程连接 Mysql Ubuntu - 绑定地址失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆