简体   繁体   English

与WordPress和Azure建立数据库连接时出错

[英]Error establishing a database connection with WordPress and Azure

I have hosted a WordPress site, http://edufunweb.azurewebsites.net/ , on Azure. 我已经在Azure上托管了一个WordPress网站http://edufunweb.azurewebsites.net/ It was working fine until I wanted to host another site. 在我想托管另一个站点之前,它运行良好。 So I went to the edufun wp-config.php file in Microsoft Webmatrix and changed the line 因此,我转到了Microsoft Webmatrix中的edufun wp-config.php文件并更改了该行

$table_prefix = 'wp_';

to

$table_prefix  = 'wp_2';

(or maybe it was the other way around) in order to have different tables in the database for each of the sites. (或者反之亦然),以便每个站点的数据库中都有不同的表。 Then I deleted the other site and now with whichever codes above I get a 然后,我删除了另一个站点,现在使用上面的任何代码,我都会得到一个

Warning: mysql_connect(): Access denied for user 'abcd'@'xxx.yyy.zzz.xx' (using password: YES) in D:\home\site\wwwroot\wp-includes\wp-db.php on line 1461
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 eu-cdbr-azure-north-c.cloudapp.net. 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.

Moreover, if I connect to http://edufunweb.azurewebsites.net/wp-admin/ 此外,如果我连接到http://edufunweb.azurewebsites.net/wp-admin/

I still get the same error. 我仍然遇到相同的错误。

Your help is highly appreciated as I need my website back on track! 非常感谢您的帮助,因为我需要我的网站恢复正常!

I don't think this is a WP multi-site issue. 我认为这不是WP多站点问题。 This typically is caused when the connection string to the host mysql server is not correct. 这通常是由于与主机mysql服务器的连接字符串不正确引起的。

Here's an easy way to test this. 这是测试的简单方法。

Open wp-config.php and locate the following lines. 打开wp-config.php并找到以下几行。

/** MySQL database username */
define('DB_USER', 'user_name');

/** MySQL database password */
define('DB_PASSWORD', 'user_password');

/** MySQL hostname */
define('DB_HOST', 'some_hostname');

Next, open your WP site in the Azure Management Portal. 接下来,在Azure管理门户中打开您的WP网站。 Go to the Configure tab and scroll down to Connection Strings. 转到“配置”选项卡,然后向下滚动到“连接字符串”。 Click "Show Connection Strings". 单击“显示连接字符串”。 Copy it into a text editor and compare the values to what you see in wp-config.php. 将其复制到文本编辑器中,然后将值与wp-config.php中看到的值进行比较。 If those values are not the same then keep both copies and do the next step. 如果这些值不相同,则保留两个副本并进行下一步。

Next, open your local shell and open mysqladmin by typing in the following, replacing the values from above here below (without single quotes), note there is no space between the -p parameter and the password value itself. 接下来,打开您的本地shell并通过键入以下内容来打开mysqladmin,在下面替换上面的值(不带单引号),请注意-p参数和密码值本身之间没有空格。

mysqladmin -u user_name -puser_password -h some_hostname

One of those connection values should be correct and if so replace the one that is not correct with the one that is. 这些连接值之一应该是正确的,如果是这样,则用不正确的值替换一个不正确的值。 If neither work, then go back to the Azure Management Portal to your site, click on Linked Resources, click the item that appears and you should be in the Clear DB management portal where you can get the correct connection information for your MySQL Database. 如果两种方法都不起作用,则返回到站点的Azure管理门户,单击“链接资源”,单击出现的项目,您应该位于Clear DB管理门户中,在这里您可以获取MySQL数据库的正确连接信息。

After you have sorted you can go configure your WP Multi-site. 排序后,您可以配置WP Multi-site。 Here is an article on how to do that for Azure Web Apps, http://azure.microsoft.com/en-us/documentation/articles/web-sites-php-convert-wordpress-multisite/ 这是有关如何针对Azure Web Apps进行此操作的文章, http://azure.microsoft.com/zh-cn/documentation/articles/web-sites-php-convert-wordpress-multisite/

hope that helps. 希望能有所帮助。

define( 'WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', '');
define('PATH_CURRENT_SITE', '');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

those lines add to config.php and check wp-admin, there is an option network admin. 这些行添加到config.php并检查wp-admin,有一个选项network admin。 Go to the network admin and after that go to the settings and setup network from Network Setup option. 转到网络管理员,然后从“网络设置”选项转到设置和设置网络。

Go to the Site option and Add New Site. 转到站点选项,然后添加新站点。

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

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