简体   繁体   English

MAMP Pro用于多个wordpress安装连接错误

[英]MAMP Pro for multiple wordpress installations connection error

Summary 摘要

I am using MAMP Pro for maintaining local copy of my wordpress website. 我正在使用MAMP Pro来维护我的wordpress网站的本地副本。 I am trying to have a separate wordpress installation, and it is giving a database connection error. 我正在尝试单独的wordpress安装,它给出了数据库连接错误。

Details 细节

I'm trying to define multiple hosts in MAMP Pro for separate wordpress installations. 我正在尝试在MAMP Pro中定义多个主机以进行单独的wordpress安装。 The default "localhost" works fine, but if I try to add another host, it doesn't work properly. 默认的“localhost”工作正常,但如果我尝试添加其他主机,则无法正常工作。

Using the new host (wordpress.dev), the browser properly launches the wordpress installation page defined in the (wordpress.dev) directory, but after inserting the database name and credentials, it gives a connection error. 使用新主机(wordpress.dev),浏览器正确启动(wordpress.dev)目录中定义的wordpress安装页面,但在插入数据库名称和凭据后,会出现连接错误。

I've double checked the database name, username, password etc. I've also tried to run it using mysql root credentials. 我已经仔细检查了数据库名称,用户名,密码等。我也尝试使用mysql root凭据运行它。 I've also given all global rights to the database user, database specific rights etc. But to no avail. 我还给了数据库用户的全部权利,数据库特定权限等但无济于事。

Since I've been using the default rights for the Document root in MAMP pro, I suspected that it could be a rights issue, I tried to assign all the rights to the System Administrator account or www but nothing worked. 由于我一直在MAMP pro中使用Document根目录的默认权限,我怀疑它可能是一个权利问题,我试图将所有权利分配给系统管理员帐户或www但没有任何效果。

If I press the "Web Start" button on Mamp Pro, the browser opens the following page ( http://localhost/MAMP/?language=English ) that describes Host as localhost. 如果我按下Mamp Pro上的“Web Start”按钮,浏览器将打开以下页面( http:// localhost / MAMP /?language = English ),将Host描述为localhost。

The complete error states as 完整错误表示为

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. 这或者意味着wp-config.php文件中的用户名和密码信息不正确,或者我们无法通过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支持论坛。

Please keep in mind that the host "wordpress.dev" is present, and when I point it in the browser, it loads the defined directory but it is unable to connect to the database using that server. 请记住主机“wordpress.dev”存在,当我在浏览器中指出它时,它会加载已定义的目录,但无法使用该服务器连接到数据库。

I tested to remove the password from the database user and the error changes to this. 我测试过从数据库用户中删除密码,错误更改为此。

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. 我们能够连接到数据库服务器(这意味着您的用户名和密码没问题),但无法选择mydb数据库。

Are you sure it exists? 你确定它存在吗?
Does the user myadmin have permission to use the mydb database? 用户myadmin是否有权使用mydb数据库?
On some systems the name of your database is prefixed with your username, so it would be like username_mydb. 在某些系统上,数据库的名称以您的用户名为前缀,因此它就像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. 如果一切都失败了,您可以在WordPress支持论坛上找到帮助。

Thanks for reading my question and any help is much appreciated. 感谢您阅读我的问题,非常感谢任何帮助。

After wasting much time, I came to know that I was forgetting to rename the configuration file from wp-config-sample.php to wp-config.php. 浪费了很多时间后,我才知道忘记将配置文件从wp-config-sample.php重命名为wp-config.php。

Although wordpress installation was asking the details to generate the configuration file but probably, the wordpress installation didn't have the permissions to generate any file on my system. 虽然wordpress安装要求详细信息生成配置文件,但可能,wordpress安装没有权限在我的系统上生成任何文件。

I use MAMP + Mac OS 我使用MAMP + Mac OS

It works with these settings in wp-config.php 它适用于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', '');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM