Support » Installing WordPress » Error establishing a database connection, after saving wp-config.php file.

  • Resolved Vishal Mukadam



    I have problem during installing software on localhost,
    I am using Ubuntu Linux, extracted the WordPress software but when I go to localhost/wordpress, it asks me for Database name, username, password, Database host, Table prefix, when I submit the data properly it shows me “Error establishing a database connection” that means I need to create “wp-config.php” file from the “wp-config-sample.php” file,
    I opening my terminal and then updating the details in wp-config-sample.php and then saving it as wp-config.php file but still I am not able go through installation.
    When I save the file as wp-config.php and then run the installation it shows “wp-config.php” file already exist.
    Let me know which guide to follow to solve this issue.


Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator t-p


    – “Error establishing a database connection” means that there is a problem with the connection to your database
    – a problem with the credentials stored in the wp-config.php file not matching what mysql expects.

    Try reviewing the following codex for some guidance:

    Also review this tutorial:



    Once you save the file as wp-config.php restart the installation process by going to them main URL of the site. If you create that file part way through the installation as you’ve done, the system still expects that it’s meant to create it itself.




    There are the following reasons to occur this error.
    1 Incorrect database login credentials
    2 Check if MySQL server is up and running

    First, you need to check in WP-config file, which login credentials have you set. You need to login through this credentials or you need to set the new login credentials in WP-config file.

    Second one, you need to check MySQL server is running and up. If you are on shared Host, you can contact your Web Hosting provider and ask them if their MySQL server is responsive. If you own VPS or Dedicated server, you need to check the MySql service is running or not.


    Thanks for the helpful replies, I finally fixed the issue a month ago but, posting this very late so sorry for that.

    The issue was with the MySQL database credentials. I had installed the LAMP on my Ubuntu machine using the command line, the reason for this problem was because I was using root user for the SQL database which used the default “UNIX or auto_socket plugin”,

    So, to fix that issue I need to set root user of MySQL to “my SQL native password” or create a new user with MySQL native password, I did and fixed that.

    Best Wishes!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Error establishing a database connection, after saving wp-config.php file.’ is closed to new replies.