Support » Installing WordPress » Error establishing a database connection

  • I followed all the directions but when I try to launch WP (or connect it to the databese) I get an error establishing a database connection.

    * I created a folder one step down from my root domain (so I can create/troubleshoot the site then move it later), then FTP’d the WP files into it: http://www.tsoup.com/schroeder
    * I accessed my cPanel, created a database, username and password.
    * Then I went to the www folder I created, signed into the WP-admin interface, got to the setup-configuration file page, added the database, username, password and localhost into the form, and I get an error message saying there is an error establishing a database connection.
    * I called my web host just to be sure and they said that “localhost” is correct.

    So what could the error be from? Do I need to add some sort of prefix to the database name because it’s one step below the root domain? I can’t figure it out.

    Thanks for your input!

Viewing 9 replies - 1 through 9 (of 9 total)
  • I just read setup directions on a different site that says I should make a copy of wp-sample-config.php, rename it wp-config.php, add the database, user, etc, to the file, then FTP it into the www folder where my WP files are located.

    I did that, reloaded the web page wherein I setup WP (one step down from root), and now I don’t even get the WP intro interface. It goes straight to the error message…Error establishing a database connection.

    So I removed wp-config.php from the www folder, and it’s back to the WP intro interface, but I’m still getting the same error message when I try to setup-config, same as before.

    Hello,

    Try resetting your MySQL password manually.
    You can find it, here: https://codex.wordpress.org/Installing_WordPress#Common_Installation_Problems

    Hope this helps.

    Regards,

    Thanks. I changed the password in my cpanel and it worked.
    I’m not sure why this could happen, though, because I switched the old password with the exact same password. Odd…

    I used to work for a hosting company, and I would see this error a lot, other times it can be caused by lack of optimization of your site, as well as heavy loads of traffic, that your host cannot keep up with on your plan.

    Thanks

    Here you may need to create separate database user with strong password instead of using cpanel user name and password. Might be this will get chance to hacker to hack the website.

    Everything about website credential like database name, user name and password etc present on config file – https://codex.wordpress.org/Editing_wp-config.php

    • This reply was modified 2 years, 8 months ago by  Anil Jadhav.

    Thank you. The password was the problem.

    Just Verify that your’re entering right credentials,
    i.e

    1. Database username: XYZ (you can find it in your Cpanel)
    2. Database user Password: XYZ_user (also in cpanel, when you created database you have to create user for database and enter a password and click on create after that you need to click on all privileges for user access)

    and thats it.

    now you can do it manually go to the wp root and find wp-config.php file and enter the follwing fields

    /** The name of the database for WordPress */
    define( ‘DB_NAME’, ‘XYZ’ );

    /** MySQL database username */
    define( ‘DB_USER’, ‘XYZ_user’ );

    /** MySQL database password */
    define( ‘DB_PASSWORD’, ‘password_mentioned’ );

    /** MySQL hostname */
    define( ‘DB_HOST’, ‘localhost’ );

    That’s it hope if you follow these instruction you will never face any issue.

    Tip: in similar situations, use wp config, set the DEBUG to true in order to see something beyond wsod (white screen of death)

    Good luck

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Error establishing a database connection’ is closed to new replies.