Question: I'm trying to set up a new WordPress site and can't get it to connect to the database.

To to try isolate the problem, I created a php file in the same directory as the WordPress app with the following code:

```
<?php
$mysqli = new mysqli('localhost:3306', 'root', 'somepassword', 'gazos');

if ($mysqli->connect_error)
    die('Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error);
else
   echo 'Good connection to gazos';
?>

```

When I execute it from the browser, it returns Good connection to gazos.

This the first part of my wp-config.php file:

```
<?php
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'gazos');

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

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

/** MySQL hostname */
define('DB_HOST', 'localhost:3306');

```

Calling the supplied WordPress index.php file results in the following error:

```
Error establishing a database connection

```

I get the same error when I remove the port from localhost.

Could the php version be too new for WordPress?

Answer: 
Replace localhost:3306 with 127.0.0.1.

When I asked this question on a wordpress forum, I was told my MySQL configuration was bad. When I asked about that problem on this forum, it was suggested that I try 127.0.0.1 in place of localhost:3306. That fixed the problem. I still don't know if my configuration is bad.
leave the port out on DB\_HOST.

`define('DB_HOST', 'localhost');`

Edit:
Try changing your mysql password and updating your wp-config.php.

Saw that [here](http://wordpress.org/support/topic/just-upgraded-to-php-54-and-site-doesnt-work).