简体   繁体   中英

Error establishing a database connection with WordPress and Azure

I have hosted a WordPress site, http://edufunweb.azurewebsites.net/ , on Azure. 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

$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/

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. This typically is caused when the connection string to the host mysql server is not correct.

Here's an easy way to test this.

Open wp-config.php and locate the following lines.

/** 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. 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. 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.

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.

After you have sorted you can go configure your 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/

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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