If your staged WordPress website shows Error establishing a database connection then it can be fixed quickly like so:
- Open the Staged website and go to Databases
- Click Users and note the Username
- Click Files and then public_html
- On the file wp-config.php click the (3 dots) and Edit
- Correct the DB_NAME and DB_USER
Finally. update the DB_NAME & DB_USER to the one noted in step 2.
For example, update from this:
// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'test_test_example_wp307' );
/** Database username */
define( 'DB_USER', 'test_test_example_wp307' );
To this:
// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'test_example_wp307' );
/** Database username */
define( 'DB_USER', 'test_example_wp307' );
This issue is extremely rare and only affects some WordPress sites imported from certain cPanel versions.