简体   繁体   中英

Error establishing a database connection while hosting Wordpress on IIS

I get this error when I install wordpress using Web Platform Installer.

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

I can successfully install it in case IIS and wordpress folder are on the same machine.

But I get this error when I install wordpress on IIS and point that application to ther folder which is on some network but other virtual machine. So, obviously IIS sees that folder (other non wordpress sites, ASP.NET are setup this way) but something else is problem. I tried putting different things inside wp-config. /** MySQL hostname */ define('DB_HOST', '127.0.0.1');

It is Windows Server 2016, and I had to change something in registry to succesfully install Wordpress, but I don't think that is problem because wordpress is now installed. But when I visit http://example.com/blogging/wp-admin/install.php I get error mentioned above.

Better add

define('WP_ALLOW_REPAIR', true);

in wp-config.php and try to repair your db connection. Sometimes adding port number with localhost ip will fix the issues, please try this too

define('DB_HOST', '127.0.0.1:8889');

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