Updating WordPress Database Configuration Settings
When changes in WordPress are done such as migrating WordPress to a live site or importing the database to a certain folder, database errors may occur. This error is as a result of WordPress being unable to connect/lias with the specified database and the wp-config.php settings being incorrect. These differences between the actual database and the previous database trigger a pop up that shows”error establishing a database connection’.
Therefore to avoid this, the correct MySQL database settings should be determined and wp-config.php files updated before any change is done.
Below we will determine how to update the wp.config.php file as well as determining your MySQL.
How to determine MySQL
- Login to cpanel
- navigate to database section and click on PhpMyAdmin
- Choose the username(database name) you would want to use from the left hand side list- it reads as wp-with three other digits
in our case we will use ryanada-wp162
- Click SQL from the taskbar above and locate the database you chose. Ensure you are familiar ti the password as well as the name you chose is well remembered.Updating wp-config.php
- Go to files- file manager and locate public-html where wordpress is usually installed
- Find wp-config.php and right click to edit
- Navigate to where you will see a database name(DB-Name) and replace it with the user name you chose previously(replace ryanada-mpya with ryanada-wp162 )
- Find DB-USER and replace it with the same username(ryanada-wp162)
- Find the DP_PASSWORD and still replace it with the password of the chosen username
- Ensure the DB_HOST setting reads as localhost(DB_localhost)
- Find $table-prefix setting and change it to the database table prefix you obtained for the chosen username
- Save the changes and visit your website with URL and the error wont occur. This shows your website can now load successfully.