• I just installed MySQL on this box, and have created a wordpress database, as well as a wordpress user with the password ‘wordpress’. I know, real original 😉

    create database wordpress;
    grant all privileges on *.* to ‘wordpress’@’localhost’ identified by ‘wordpress’ with grant option;

    I verified that I can log into MySQL with -u wordpress -p wordpress, so I know the account is good. I’m also able to change the database to wordpress via ‘use database wordpress’, and I even created a table inside the database, just to make sure I’m not crazy.

    Here’s the problem:

    When I try to configure WordPress, I supply the following criteria:

    Database name: wordpress
    User Name: wordpress
    Password: wordpress
    Database Host: localhost (yes, it’s running on the local machine)
    Table Prefix: wp_

    However, when I try connecting I get a message to the effect that it’s unable to establish a connection to the database. Meanwhile using the exact same credentials, I’m able to log in manually. I’ve checked typing and spelling, and this is hosted on my local box, so there’s no special hosting configuration I need to put in (e.g. with Bluehost).

    Any ideas?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    However, when I try connecting I get a message to the effect that it’s unable to establish a connection to the database.

    What is the *exact* message?

    WordPress has two possible error messages when it comes to the database connection:

    “Error establishing a database connection” – The Host name or User Name or Password is wrong, or something else prevented connection. Basically, this means that the call to mysql_connect failed. Could fail for a dozen reasons, there’s no way to tell. All it knows is that PHP won’t connect to the database. It does not know why.

    “Can’t select database” – The Database name is wrong. Basically this means that the call to mysql_select_db failed.

    Thread Starter donquixote235

    (@donquixote235)

    It’s the first message – for whatever reason, it’s not seeing the database server at all (I’m assuming).

    If it’s any help, the box is Windows XP with PHP enabled via IIS. I also have MS-SQL installed; although I don’t think that it would cause a conflict of some sort, I’m not entirely ruling it out.

    I was concerned that perhaps PHP requires some tampering to connect to MySQL, but according to what I’ve read, PHP4 on Windows requires no configuration, as MySQL is set up right out of the box.

    Thread Starter donquixote235

    (@donquixote235)

    To continue with the problem…

    I fixed the main issue; I had to set the password within mysql using OLD_PASSWORD(); once I did that, it was able to connect to the database.

    However I’m now seeing the same error message again, except later in the installation. I make it through setup-config.php just fine, but when I move to the next step (install.php) it returns a “cannot connect” error again. Obviously it can connect to the database, as it just did in the prior step.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    according to what I’ve read, PHP4 on Windows

    If you have control over this box, you might want to install PHP5 instead. I’ve had much more success with PHP5 installations on Windows boxes before.

    Thread Starter donquixote235

    (@donquixote235)

    I thought that it wasn’t recommended to have WordPress running on PHP5?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Dunno where you read that. It works fine on PHP 5. I run all my sites on PHP 5. I use PHP 5.2 and up, usually.

    Thread Starter donquixote235

    (@donquixote235)

    I’ve installed PHP 5, and now I have a new problem… it doesn’t see MySQL at all. When I use PHPINFO(), it shows no entry for MySQL. Looking at the php.ini file however, all of the values are unremarked as they should be.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    So the mysql.dll is uncommented in the PHP.INI file? Or did you uncomment it?

    Restart the server after you change the PHP.INI file.

    Thread Starter donquixote235

    (@donquixote235)

    It’s uncommented. I’ve restarted the server more than a couple of times.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘“Error establishing a database connection” – bear with me’ is closed to new replies.