1

我正在尝试从我的 IP 地址连接到我正在帮助修复的移动网络应用程序,以便我可以在我的 Android 手机上对其进行测试。但是,当我从 localhost 和我的 ip 地址访问它时会显示登录屏幕,它只会让我从 localhost 地址登录——它甚至不能从 ip 地址连接。

我正在运行 MAMP Pro 并取消选中“仅允许本地访问”。我进入 MySQL my.cnf 并将绑定地址从 127.0.0.1 更改为我自己的 IP。我还注释掉了“MAMP_skip-networking_MAMP”行。然后,我创建了一个与 config.php 中的用户匹配的用户,具有对数据库的完全访问权限,并将其主机设置为 %。

在 config.php 文件中,我尝试将主机名更改为:

  • 本地主机
  • 本地主机:[端口号]
  • [IP地址]
  • [IP 地址]:[端口号]
  • /Applications/MAMP/tmp/mysql/mysql.sock

依然没有。当我尝试从我的 IP 访问该站点时,我仍然无法登录。任何帮助/方向将不胜感激..谢谢!

4

1 回答 1

0

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.

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:

how-do-i-enable-remote-access-to-mysql-database-server

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';

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 - Adding Users -- look for the section mentioning wildcards.

于 2012-05-26T11:24:56.670 回答