WordPress : Error establishing database connection
If you’ve uploaded WordPress onto your hosting account and its getting the below error .
It might be that your Database credentials are incorrect in the wp-config.php file. To fix this problem, follow the instructions below:
- FTP connect to your hosting account using your account FTP details , Or you can login to cPanel and access the File Manager.
- Open the wp-config.php file (located in the webroot folder, in cPanel it would be the public_html folder)
- Make sure your database name, username, password and hostname are correct (you can find instructions below depending on your hosting)
- Find the database string below in the wp-config.php file and replace the relevant credentials with the correct information.
// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'your-databas-ename' );
/** Database username */
define( 'DB_USER', 'your-datbase-username' );
/** Database password */
define( 'DB_PASSWORD', 'your-database-password' );
/** Database hostname */
define( 'DB_HOST', 'localhost' );
/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
- Re-upload the edited wp-config.php file
Cloud Hosting : Database credentials
To find your database name, hostname, username and password:
- Log into the Console
- Click the domain you want to manage
- Click Database and you will see your database under the Current Databases heading
- Click View under Credentials
- In the pop up you'll find log in information and your hostname
cPanel Hosting : Database credentials
- Log into the Console
- Click the domain you want to manage
- Click cPanel Hosting
- Under hosting settings, click Log into cPanel interface
- Under the Databases section click MySQL Databases
- On this page you’ll find the database name
- Scroll down to Current Users and your will find the database user which will connect to the database
- In the Current Users section you can reset your database user password
For cPanel users the hostname is always localhost
Success! You’ve done the steps for this article. If you’re unable to follow these steps, or receive an error in doing so, please submit a support request through your console or call us on 1300 638 734 for further assistance.
Updated 6 months ago