Forums

[resolved] Error establishing a database connection (20 posts)

  1. DJL
    Member
    Posted 4 years ago #

    I keep getting the message that there is an "Error establishing a database connection". As I understand the wp-config-sample.php file (which I have renamed "wp-config.php" before uploading) I only have to enter name of the database, username and password. See below (password written in letters in my file, of course). Do I have to fill in somthing in "define('DB_COLLATE', '');"
    as well?

    <?php
    // ** MySQL settings ** //
    define('DB_NAME', 'viarecta_dk_db'); // The name of the database
    define('DB_USER', 'viarecta'); // Your MySQL username
    define('DB_PASSWORD', '********'); // ...and password
    define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
    define('DB_CHARSET', 'utf8');
    define('DB_COLLATE', '');

  2. moshu
    Member
    Posted 4 years ago #

    I only have to enter name of the database, username and password.

    And, eventually, the DB_HOST (aka database server) - because it is not always "localhost".

    What is the exact error message you get? (there are more than one)

  3. DJL
    Member
    Posted 4 years ago #

    Full error message:

    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?
    If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

  4. moshu
    Member
    Posted 4 years ago #

    the username and password information in your wp-config.php file is incorrect or we can't contact the database server at localhost

    If you are sure that the username and pw is correct - then the only issue is with "localhost".
    Check in your hosts site admin panel (where you created the DB) what should be the database server or mysql server.

  5. DJL
    Member
    Posted 4 years ago #

    I am sure about username and password. I didn't create the DB myself. It was already there - or maybe my old webmaster created it. Anyhow, when I log in to the MySQL admin it says:

    Server: Localhost via UNIX socket

    Writing "Localhost via UNIX socket" in the file didn't work either.

  6. moshu
    Member
    Posted 4 years ago #

    Another thought: does the db user have all the privileges? and, more importantly, did you add the user to the db?

  7. DJL
    Member
    Posted 4 years ago #

    Ehhhmm. I'm afraid you lost me there. I've always logged into the DB with the same user and pw and so did my webmaster. there is only this one user and pw.

  8. DJL
    Member
    Posted 4 years ago #


  9. moshu
    Member
    Posted 4 years ago #

    Actually, unless you make a backup of your data, for installing WP there is no need to login into the DB.

    So, what kind of site admin is offered by your host?
    cPanel? Plesk? something else?
    Who is your host? - there are always control panel specific and/or host specific info if we/you know what are you looking for.

  10. isleo1
    Member
    Posted 4 years ago #

    I am having the same problem. I've gone through all the steps and nothing is working.

  11. moshu
    Member
    Posted 4 years ago #

    isleo1,

    don't double post - keep it in your own thread!

  12. DJL
    Member
    Posted 4 years ago #

    my host is a Danish webhotel host called wannafind.dk. I log in on the site mysql8.wannafind.dk and then I enter a site which is pretty basis to look at. It says "Localhost" and "phpMyAdmin - 2.11.1" as headlines.... don't know if this is the right word in English.

    I only logged into the db to be sure about username and pw. I honestly don't know what "plesk" or "cPanel" is.... sorry.

  13. moshu
    Member
    Posted 4 years ago #

    Did you try this instead of "localhost"
    mysql8.wannafind.dk ?

  14. roambe
    Member
    Posted 4 years ago #

    You log in to mysql8.wannafind.dk? Then that's presumably your database server. Substitute "localhost" with that URL ("mysql8.wannafind.dk").

  15. DJL
    Member
    Posted 4 years ago #

    Moshu, I could kiss you! "welcome" now appears on my screen!

    Thank you!

  16. moshu
    Member
    Posted 4 years ago #

    Hmm... Is this the domain linked to your profile here?
    If I click on it it goes to the install.php file, which is bad - anybody could overwrite your installation.

    As a temporary solution, remove the install.php file!

  17. DJL
    Member
    Posted 4 years ago #

    Ehh, but I have to install it! which is done now.

  18. DJL
    Member
    Posted 4 years ago #

    I think I got it. What you meant. I've deleted install.php, logged in and changed the password.

  19. jaibeellen
    Member
    Posted 4 years ago #

    Hello.
    I'm having the same problem DJL was having establishing a database connection. However, when I tried to sub my "localhost" out for the actual URL, nothing changed. Is there something else that could be wrong?

    JGB

  20. moshu
    Member
    Posted 4 years ago #

    Try to read more carefully: the OP did NOT use the actual URL of the blog but the address of the MySQL server. Big difference!

Topic Closed

This topic has been closed to new replies.

About this Topic