How to Change Database Name, User, and Password in WordPress

Changing the database name, user, and password in WordPress might be necessary when migrating your site to a new server or updating your database credentials for security reasons. In this tutorial, we’ll guide you through the process of updating these details in the wp-config.php file.

Step 1: Backup Your WordPress Site

Before making any changes, it’s essential to create a backup of your WordPress site. This includes both the website files and the database. You can use a backup plugin or your hosting provider’s backup tools.

Step 2: Locate the wp-config.php file

Access your WordPress installation directory and find the wp-config.php file. You can use a text editor or an FTP client to edit this file.

Step 3: Identify Database Configuration Settings

In the wp-config.php file, look for the section that defines the database configuration. It typically looks like this:

define('DB_NAME', 'your_database_name');
define('DB_USER', 'your_database_user');
define('DB_PASSWORD', 'your_database_password');
define('DB_HOST', 'localhost');

Step 4: Change Database Name, User, and Password

Update the values for DB_NAME, DB_USER, and DB_PASSWORD with your new database name, user, and password. For example:

define('DB_NAME', 'new_database_name');
define('DB_USER', 'new_database_user');
define('DB_PASSWORD', 'new_database_password');

Step 5: Save the Changes

Save the wp-config.php file.

Step 6: Test Your Site

Visit your WordPress site to ensure it’s working correctly with the updated database credentials. If you encounter any issues, double-check the values in the wp-config.php file.


Changing the database name, user, and password in WordPress involves updating the wp-config.php file with the new credentials. This is a crucial step when migrating your site or updating database credentials for security reasons.

Always make sure to back up your site before making such changes, and test your site thoroughly to ensure everything is functioning as expected.

Feel free to share this tutorial with others who may need to update their WordPress database credentials!