MAMP Pro for multiple wordpress 安装连接错误

MAMP Pro for multiple wordpress installations connection error

总结

我正在使用 MAMP Pro 维护我的 wordpress 网站的本地副本。我正在尝试单独安装 wordpress,但出现数据库连接错误。

详情

我正在尝试在 MAMP Pro 中为单独的 wordpress 安装定义多个主机。默认的 "localhost" 工作正常,但是如果我尝试添加另一个主机,它就不能正常工作。

使用新主机(wordpress.dev),浏览器正常启动在(wordpress.dev)目录中定义的wordpress安装页面,但在插入数据库名称和凭据后,它给出了一个连接错误。

我仔细检查了数据库名称、用户名、密码等。我还尝试使用 mysql root 凭据 运行 它。我还授予了数据库用户所有全局权限、数据库特定权限等。但无济于事。

由于我在MAMP pro中一直使用Document root的默认权限,我怀疑这可能是一个权限问题,我试图将所有权限分配给系统管理员帐户或www但没有任何效果。

如果我在 Mamp Pro 上按下 "Web Start" 按钮,浏览器会打开以下页面 (http://localhost/MAMP/?language=English),该页面将 Host 描述为 localhost。

完整的错误状态为

Error establishing a database connection

This either means that the username and password information in your wp-config.php file is incorrect or we can't contact the database server at wordpress.dev. This could mean your host's database server is down.

Are you sure you have the correct username and password?
Are you sure that you have typed the correct hostname?
Are you sure that the database server is running?

If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

请记住主机 "wordpress.dev" 存在,当我在浏览器中指向它时,它会加载定义的目录,但无法使用该服务器连接到数据库。

我测试了删除数据库用户的密码,错误变成了这个。

Can’t select database

We were able to connect to the database server (which means your username and password is okay) but not able to select the mydb database.

Are you sure it exists?
Does the user myadmin have permission to use the mydb database?
On some systems the name of your database is prefixed with your username, so it would be like username_mydb. Could that be the problem?

If you don't know how to set up a database you should contact your host. If all else fails you may find help at the WordPress Support Forums.

感谢阅读我的问题,非常感谢任何帮助。

浪费了很多时间后,我才知道我忘记将配置文件从 wp-config-sample.php 重命名为 wp-config.php.

虽然 wordpress 安装询问了生成配置文件的详细信息,但可能 wordpress 安装没有在我的系统上生成任何文件的权限。

我用MAMP + Mac OS

它适用于 wp-config.php

中的这些设置
define('DB_NAME', 'your name_db');
define('DB_USER', 'root');
define('DB_PASSWORD', 'root');
define('DB_HOST', 'localhost:8889');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');