WordPress Won't Connect to DB, But Test Code Does
-
I closed my last question because I thought my problem wasn’t WordPress related. After chasing some ghosts, I’m back to WordPress as the culprit. I’m getting the infamous “Error establishing a database connection” message when I invoke index.php on a brand new WordPress install. This is relevant information from my wp-config:
define(‘DB_NAME’, ‘gazos’);
define(‘DB_USER’, ‘root’);
define(‘DB_PASSWORD’, ‘somepassword’);
define(‘DB_HOST’, ‘localhost:3306’);I also tried localhost without the port and got the same error.
To isolate the problem, I ran the following code from the same directory as WordPress via the browser:
<?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'; ?>I get a good connection. It fails if I remove the port. I’m running PHP 5.4.13 and MySQL 5.0.10. Could it be that my PHP version is too new?
The topic ‘WordPress Won't Connect to DB, But Test Code Does’ is closed to new replies.