MySQL-使用IP地址连接到远程服务器 [英] Mysql - connect to remote server using IP address

查看:354
本文介绍了MySQL-使用IP地址连接到远程服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PHP和MySQL建立数据库连接,唯一的变化是我试图使用服务器IP地址从本地计算机访问远程服务器.

I am using PHP and MySQL to make a database connection, the only change is that I am trying to access my remote server from my local computer using my server IP address.

mysql_connect("x.xx.xx.x","username","password") or die(mysql_error());

,我得到的错误是Unable to connect to the given host.用户拥有所有特权和权限.

and the error I am getting is Unable to connect to the given host. The user has all privileges and rights.

推荐答案

大多数默认安装的MySQL仅侦听本地计算机.

Most default installs of MySQL only listen to the local machine.

在服务器上的my.cnf中查找bind-address设置,并确保它正在侦听目标IP地址.您可能还需要确保未打开skip-networking

Look for the bind-address setting in my.cnf on the server, and make sure it's listening on the IP address you're targetting. You may also need to ensure skip-networking isn't switched on!

或者(不太安全!)以下内容将其设置为侦听所有地址-本地和远程:

Alternatively (and less securely!) the following will set it up to listen on all addresses - local and remote:

bind-address = 0.0.0.0

这篇关于MySQL-使用IP地址连接到远程服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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