Wordpress, IIS 7 & MySQL can't contact the database server

tbonehwd
tbonehwd used Ask the Experts™
on
After a painfull day I have php version 5.2.10, MySQL version 5.0.83 and phpMyAdmin version 2.11.9.5 all working (a feat in itself). I am using the FASTCGI for php using IIS 7 if this helps and this is Windows Server 2008.

In phpMyAdmin I created a database called 'wordpress' with a user 'wpuser' and granted all privileges to wpuser all is good so far. I have updated the wp-config.php file you can look at the full file in the code area. When I try to go to http://siteipaddress/wp-admin/install.php i get the following page:

----------------------------------------------------
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 localhost. 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?
------------------------------------------------------
The MySQL server is not down.... I can access it with phpMyAdmin, I have repeated my steps to many times to tell and not sound like a idiot any help here would be greatly appreciated.

Thank you


<?php
/** 
 * The base configurations of the WordPress.
 *
 * This file has the following configurations: MySQL settings, Table Prefix,
 * Secret Keys, WordPress Language, and ABSPATH. You can find more information by
 * visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
 * wp-config.php} Codex page. You can get the MySQL settings from your web host.
 *
 * This file is used by the wp-config.php creation script during the
 * installation. You don't have to use the web site, you can just copy this file
 * to "wp-config.php" and fill in the values.
 *
 * @package WordPress
 */
 
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');
 
/** MySQL database username */
define('DB_USER', 'wpuser');
 
/** MySQL database password */
define('DB_PASSWORD', 'wppass');
 
/** MySQL hostname */
define('DB_HOST', 'localhost');
 
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
 
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
 
/**#@+
 * Authentication Unique Keys.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define('AUTH_KEY', 'mickey do is awesome');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
/**#@-*/
 
/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each a unique
 * prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = 'wp_';
 
/**
 * WordPress Localized Language, defaults to English.
 *
 * Change this to localize WordPress.  A corresponding MO file for the chosen
 * language must be installed to wp-content/languages. For example, install
 * de.mo to wp-content/languages and set WPLANG to 'de' to enable German
 * language support.
 */
define ('WPLANG', '');
 
/* That's all, stop editing! Happy blogging. */
 
/** WordPress absolute path to the Wordpress directory. */
if ( !defined('ABSPATH') )
	define('ABSPATH', dirname(__FILE__) . '/');
 
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Use phpMyAdmin to check permissions. You want to ensure the wordpress user has access to the wp database using the host that the wp user is configured to use (most likely localhost). Failing that (due to phpMyAdmin user permissions with MySQL), logon to the mysql console as root and check permissions.

I suspect you have an incorrect host attached to the wp user. Try using the wildcard host (%) for the wp user.
Try changing your host to the actual IP address of the database server.

Author

Commented:
v2Media:  As you can see below wpuser is using the % wildcard and ALL PRIVILEGES  are granted on database wordpress
Server: localhost:3307   Database: wordpress

Users having access to "wordpress"  User Host Type Privileges Grant Action
root  localhost global  ALL PRIVILEGES  Yes  
wpuser  % global  ALL PRIVILEGES  Yes  

rondelrosario: I have looked around and havent found an answer how do you change the host?

Thank you,

Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Author

Commented:
I just tried installing Joomla and I get the same results when connecting to my sql (Unable to connect to the database:Could not connect to MySQL)... phpMyAdmin has no problem accessing mySQL I have added databases updated users etc... I just don't get it what am I missing?
Commented:
Problem solved when it asked for host i put in localhost however I just tried localhost:3307 and now it works...

Commented:
"host that the wp user is configured to use (most likely localhost)."
Maybe you have some sockets blocked. Check your firewall to clear things up.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial