• Hello,

    I am new to WordPress. Basically, I am going to have to administer a wordpress site for a charitable organization I help out, but I want to have a test bed system that I can play with before “going live” with the thing.

    I have successfully installed wordpress on my Ubuntu 10.10 laptop and was accessing as just fine localhost…

    Then I rebooted, and I began to receive this error…

    Database Error: Error Establishing a Database Connection

    … when I go to http://localhost/wordpress

    Seems like it should be pretty simple, but I have not been able to find any troubleshooting info on this error online.

    Thanks so much for your help.

    B

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi!

    First, make sure MySQL (or the database server you’re using) is running.

    If yes, check your wp-coonfig.php values.

    Moderator t-p

    (@t-p)

    -First, double check your wp-config.php file settings for the database name, database username and database password. This is where most errors occur.

    -Then check that you don’t need to change the database host from “localhost” to something else. You can get that info from your hosting provider.

    -Check you have actually created a database with the same database name as is in your wp-config.php file.

    -Last, but not least, if all that information is correct your database probably has a problem with it.

    There are also many threads on this topic on these forums: http://wordpress.org/search/Error+establishing+a+database+connection?forums=1

    See if this video helps: http://educhalk.org/blog/2009/03/error-establishing-a-database-connection-how-to-fix-this-wordpress-error/

    Thread Starter SwarfEye

    (@swarfeye)

    Ok,

    So, I’m not sure how to check and see that mysql is in fact running. Nor am I sure what the correct username and password for the database would be.

    I’ve reviewed the installation instructions, and I don’t see any indication that I was ever asked to enter this information… and so I don’t know it at this point.

    I was asked to provide a root password for the mysql installation. This password I have, but I have not been able to figure out how to do anything with mysql. I am not able to log in or anything.

    Suggestions?

    B

    Try running http://localhost/wordpress/wp-admin/install.php and tell us what you see.

    The database user and password aren’t created while installing, they should already exist. If you are sure that you won’t use this MySQL database for anything else than WordPress, you can use root but it would be safer to create a new user. phpMyAdmin is a great tool for MySQL administration.

    Thread Starter SwarfEye

    (@swarfeye)

    Ok, I figured it out, but I have to say that the documentation for the newby is quite patchy.

    So, just in case someone in a similar spot comes across this post, I will list all the things that need to happen and how to do it (it’s the how to do it that appears to be missing from everything else!)

    First up, it was my wp-config.php file that was screwy. For some reason the default install leaves a file called wp-config.php which is entirely not like anything that is supposed to go there. I replaced it with wp-config-sample.php.

    Then you need to fill in the new wp-config.php file. For me, all I had to set were the database name, user name, and user password… but then there is the question of how do you find this information???

    1) Log into mysql by using the command…

    mysql -u root -p

    Give mysql the root password you gave it during installation. You should end up at the mysql command prompt.

    2) Find out what the name of the database is. At the mysql command prompt use the command…

    show databases;

    In this case, I found out that the database was named “wordpress”

    3) Find out what the mysql username is. Use the command…

    select User from mysql.user;

    … this should yield a list of users, but on a new install it will be quite short. For me it was obvious that the username I was looking for was “wordpress”.

    4) Set the wordpress user password. I was unable to determine what the default installation wordpress user password was, so this is how I figured out what to in wp-config.php file.

    SET PASSWORD FOR 'user'@'host' = PASSWORD('newpassword');

    Plug these new values into the new wp-config.php file. Then restart apache. On the Ubuntu command line that is…

    sudo /etc/init.d/apache2 restart

    … Then everything worked again!

    B

    “Ok, I figured it out, but I have to say that the documentation for the newby is quite patchy.”

    It seems you haven’t found the Installation page of the documentation…

    Thread Starter SwarfEye

    (@swarfeye)

    Quite right.

    That would have been very useful… funny that it didn’t come up in all my searching on the subject.

    I was using this as my main document…

    https://help.ubuntu.com/community/WordPress

    I will suggest that they link to the “Installation” page on this document.

    Thanks.

    B

    Moderator t-p

    (@t-p)

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

The topic ‘Database Error: Error Establishing a Database Connection’ is closed to new replies.