MySQL能在本地而不是远程连接 [英] MySQL can connect locally but not remotely

查看:168
本文介绍了MySQL能在本地而不是远程连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的IP地址连接到移动网络应用程序,我帮助解决,所以我可以测试它在我的Andr​​oid手机上。然而,在登录屏幕显示出来,当我从本地主机和我的IP地址来访问它,只会让我从本地主机登录寻址,它甚至不从IP地址进行连接。

I'm trying to connect from my ip address to a mobile web app I'm helping to fix so I can test it on my Android phone. However, while the login screen shows up when I access it from localhost AND my ip address, it will only let me login from the localhost address- it doesn't even connect from the ip address.

我运行MAMP Pro和已取消选中了仅允许本地访问。我去到MySQL的my.cnf,改变从127.0.0.1绑定地址到我自己的IP。我还评论了MAMP_skip-networking_MAMP行。然后我做了与在config.php用户相匹配用户,可以完全访问数据库,并设置其主机%。

I'm running MAMP Pro and have unchecked the "Allow local access only". I went into MySQL my.cnf and changed the bind-address from 127.0.0.1 to my own IP. I also commented out the "MAMP_skip-networking_MAMP" line. I then made a user that matches up with the user in config.php, has full access to the database, and set their host to %.

在config.php文件,我试图改变主机名:

In the config.php file, I've tried changing the hostname to:


  • 本地主机

  • 本地主机:[端口号]

  • [IP地址]

  • [IP地址]:[端口号]

  • /Applications/MAMP/tmp/mysql/mysql.sock

不过..没有。我还是当我尝试从我的IP访问该网站无法登陆。任何帮助/方向是极大的AP preciated ..谢谢!

Still.. nothing. I still can't login when I try to access the site from my IP. Any help/direction would be greatly appreciated.. thank you!

推荐答案

这个问题是不是与客户,最有可能的,但与服务器的。大多数MySQL服务器配置(我觉得默认情况下)拒绝连接尝试不在本地。给我几秒钟就可以拉起配置/信息架构更改,以使你可以改变这一点。

The issue isn't with the client, most likely, but with the server. Most MySQL servers are configured (I think by default) to refuse connection attempts that aren't local. Give me a few seconds to pull up the config/info schema change to make so that you can change this.

警告,这是一个坏主意,开拓分贝所有请求。你想要么让它开放给所有的IP请求从一个用户,或者允许任何用户请求从一个特定的IP(甚至更好,将二者结合起来,并让这个只有特定的用户可以从特定IP地址的请求)

Warning, it's a bad idea to open up the db to all requests. You'll want to either make it open to all IP requests from one user, or allow requests from any user from a specific IP (or even better, combine the two and make it so that only certain users can make requests from specific IPs).

下面是一个很好的(但同样危险)教程:

Here's a good (but again dangerous) tutorial:

然而DO-我启用远程访问到MySQL数据库服务器

最简单的方式做到这一点,如果我没有记错的话,是运行以下查询:(假设你为超级管理员

The simple way to do it, if I'm not mistaken, is to run the following queries: (assuming you're as "superadmin":

USE information_schema;
UPDATE USER_PRIVILEGES SET Host='%' WHERE user='superadmin';
FLUSH PRIVILEGES;
USE mysql;
UPDATE user SET Host='%' WHERE user='superadmin';

以上基本上授予MySQL数据库的超级管理员访问权限(如果尚未批准),然后切换到任何IP的DB和授予超级管理员权限。再次,按照提供看怎么每个用户和每个IP调整这个链接,否则你正在打开自己受到伤害的世界只用一记漂亮的MySQL GUI。

The above basically grants the superadmin access to the mysql db (if not already granted), then the switch to that db and grant superadmin access from any IP. Again, follow the links provided to see how to tweak this per user and per IP, otherwise you are opening up yourself to a world of hurt just to use a nifty MySQL GUI.

有可能会比上述(可能需要重新启动等)更复杂。另一个很好的文章是:

It may be more complicated than the above (a restart may be required, etc.). Another good article is:

MySQL的 - 将用户添加 - 寻找部分提通配符。

MySQL - Adding Users -- look for the section mentioning wildcards.

这篇关于MySQL能在本地而不是远程连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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