Support » Installing WordPress » Cannot connect to Database

  • Hi,

    Having just started with WordPress, I tried to access my WP-Admin but it stated “Error – invalid username”. So, I set up a new user, added them to the DB and deleted the old user.

    The new user has all privileges but when logging in it states:

    “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? “

    …Should I have done something differently??

Viewing 4 replies - 1 through 4 (of 4 total)
  • This either means that the username and password information in your wp-config.php file is incorrect or

    – Most logical thing to check first-

    In the files that you uploaded to your server you will find one named wp-config-sample. Start by renaming this file to wp-config (if you have not already done so).

    Open the wp-config file and find the following (starts around line 3):

    define(‘DB_NAME’, ‘putyourdbnamehere’); // The name of the database

    define(‘DB_USER’, ‘usernamehere’); // Your MySQL username

    define(‘DB_PASSWORD’, ‘yourpasswordhere’); // …and password

    Make sure the information that you entered for database name, the database user name, and that users password, are all identical to the db user, name, and pwd you set up in your database. Save the file and then upload it to your WordPress installation location and attempt to install again.

    You will also find a very nice outline of these steps located in the “readme” document in the WordPress file you downloaded. Opens up in your browser for easy reference.

    Hi there

    Many thanks for your response.

    The file you are talkig about….is it the WP Config.php file I can see in file manager on my cPanel?

    I will try your guidance when I get back from work this evening as it seems to be clear what I need to do. Thanks for directing me to the ReadMe info as well

    I’m new to this so the help is really appreciated


    Yes it is. You obviously have already renamed that file to the right name, all you need to do now is to edit it and insert your 3 names as explained above by organicw

    do you have the cPanel username prefixed to your db name and db username ?

    Also, have you added the user to the db in mysql area in cPanel ?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Cannot connect to Database’ is closed to new replies.