How To Change Database Configuration in WordPress
A WordPress website, or any website for that matter, cannot work without a database. Using a database is an organized way of storing information and is accessible via phpMyAdmin in cPanel. All the information shown on your website are requested from the database.
Vodien web hosting plans provide more than one database. Correct database configuration is needed to make sure your WordPress website is requesting the data from the correct database. Incorrect database configuration results to an error page on your WordPress website as shown in the screenshot below.
The goal is for the wp-config.php file of your WordPress website to have the correct database name, database user, and database password.
- Secure a backup of WordPress website files.
- Secure a backup of WordPress database SQL file.
- Check the details of the new version and make sure that it is compatible with the current WordPress version you are using.
1. Check current database details in wp-config.php file.
NOTE: If you can’t find the wp-config.php file in your website files, create one or check your backup files and upload it to your website directory.
- Log in to cPanel.
- Click the File Manager button under Files category.
- Access your WordPress website files and right-click on wp-config.php file.
TIP:
- The main domain’s website files are in public_html folder
- An addon domain’s website files are in the addon directory
- A subdomain’s website files are in the subdomain’s directory
- Click Edit.
- Click Edit on the pop-up.
- Take note of the DB_NAME, DB_USER, and DB_PASSWORD which are on lines 23, 26, and 29 respectively. The values are in between the single quotes (‘).
2. Check the database details in MySQL Databases.
- In cPanel, click MySQL Databases in Databases section.
- Under Current Databases, check if the DB_NAME is on the list with its corresponding Privileged User. The privileged user should be the DB_USER in your wp-config.php file.
- If both DB_NAME and DB_USER matched with what’s in the wp-config.php file, it might be the password that is mismatched. The DB_PASSWORD can’t be seen but can be reset. Copy the DB_PASSWORD from wp-config.php file and use it as the new password.
- In MySQL Databases, scroll down to Current Users.
- Click on the corresponding Change Password link of the DB_USER.
- Enter the copied password from Step 3 in the two empty boxes.
NOTE: This is not a password that you will use from time to time so it’s okay to use a long and complicated one. Just make sure to take note of the password so that you can put it later in wp-config.php file.
- Click the Change Password button.
- Check the website if it’s already working. If the error stays the same, proceed to the next steps below.
3. Edit wp-config.php file with the correct information.
- Open the wp-config.php file and edit the following with the correct database information.
- Replace the database name in between the single quotes (‘) on line 23
- Replace the database username in between the single quotes (‘) on line 26
- Replace the database password in between the single quotes (‘) on line 29
- Save changes.
- Check your website if it’s now working.
Missing Database
If the database is missing, follow the steps below.
- Create a database and its user.
- Import your database backup to phpMyAdmin.
- Edit wp-config.php file with the correct information.
Do not hesitate to contact our Singapore or Australia Support Team if you have further questions.