Skip to main content
Call us
Phone numbers and hours
Help Center

Explore our online help resources

Help

GoDaddy Help

Fix Error establishing a database connection in WordPress

WordPress uses connection strings to know which database to connect to. When your site is not connected to your database, it displays the Error establishing a database connection notification. To resolve this error, update the connection strings on your WordPress site.

Required: You'll need the following to complete all steps in this article:
  • An FTP app to open and edit your site files. There are many third-party FTP apps available, we recommend the FileZilla FTP app.
  • A text editor to make the necessary changes in WordPress files. There are many third-party text editors available, we recommend Notepad++. Do not edit files with a word processing application like Microsoft Word.
  • The database name, username, password, and host name for your WordPress site. Find these details for your Linux Hosting with cPanel, Windows Hosting with Plesk, or Managed WordPress plan. If you’re using cPanel or Plesk, you’ll need to reset and use a new password.
Warning: You should always back up your site before performing any troubleshooting.
  1. Sign in to phpMyAdmin.
  2. In phpMyAdmin, in the left menu, select the name of the database your site uses.
  3. Make note of the database prefix. The database prefix is appended to the table names (for example, if you see the following database tables: wp_3f_options, wp_3f_ posts, wp_3f_postmeta, etc., your database prefix is wp_3f_).
  4. Connect to your hosting account with FTP. Find and open the folder your WordPress site is in.
  5. In the wp-config.php file, find the section that looks like this example:
    /** The name of the database for WordPress */
    define('DB_NAME', 'yourdatabasename');
    /** MySQL database username */
    define('DB_USER', 'yourusername');
    /** MySQL database password */
    define('DB_PASSWORD', 'yourpassword');
    /** MySQL hostname */
    define('DB_HOST', 'yourhostname');
    
    $table_prefix  = 'yourtableprefix';
  6. Check if the information in this file matches the database details you found earlier.
    • yourdatabasename: Replace this with your MySQL database name.
    • yourusername: Replace this with your MySQL username.
    • yourpassword: Replace this with your MySQL password.
    • yourhostname: Replace this with your MySQL host name.
    • yourtableprefix: Replace this with your table prefix.

    Note: If any of the information in the wp-config.php file doesn't match your database details, then update the file with the correct information.

  7. Save the updated file.
  8. Verify your site is back online by visiting your site with private browsing mode in Chrome, Firefox, or Edge.

More info