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

After a painfull day I have php version 5.2.10, MySQL version 5.0.83 and phpMyAdmin version 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

 * 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

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

tbonehwdAuthor 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?
tbonehwdAuthor Commented:
Problem solved when it asked for host i put in localhost however I just tried localhost:3307 and now it works...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
"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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.