Error Establishing a Database Connection Solution
I am writing this post because I have faced this issue and search a lot for this. Error establishing a database connection occurs while you try to shift a wordpress website from one server to another. This occurs because of database location and credentials change. After shifting your website and transfer your database, open your main directory where wordpress is installed on new server.
Check for the following…
- Open the file wp-config.php
- Set the DB_NAME, DB_USER, DB_PASSWORD and DB_HOST.
- Set all these according to your new host.
If your hosting account is based on cPanel, then you can write “localhost” for DB_HOST. For other services such as GoDaddy, you have to put the DB_HOST name in the form of URL that can be checked on Database details.
Please always try to export database using mysqldump and import with same way via mysql command to fully transfer the database. If there is any problem regarding wordpress website shifting, you can comment below.