Yogesh Chauhan's Blog

How to update database configurations in WordPress?

in WordPress on December 26, 2021

I briefly discussed about this in the previous wp-config.php basics post:

An Introduction to wp-config file in WordPress

Let’s recap that.

To update the database configurations you need to change the contents inside the wp-config.php file.

When you’re setting up your website on a new server, you need to change your database configurations. You should be able to get that from your server providers.

To change the database configurations, you need to have these information handy.

  • Database Name
  • Database Username
  • Database Password
  • Database Host
    • In some cases you might need a port number, Unix socket file path or pipe.

Set Database Name

Add this line of code in your wp-config.php file to set your WordPress MySQL database name.

Add your database name instead of DATABASE_NAME.


define( 'DB_NAME', 'DATABASE_NAME' ); 

Set Database User

Add this line of code in your wp-config.php file to set your username.

Add your database username instead of USERNAME.


define( 'DB_USER', 'USERNAME' );

Set Database Password

Add this line of code in your wp-config.php file to set your WordPress MySQL database password.

Add your MySQL database password instead of PASSWORD.


define( 'DB_PASSWORD', 'PASSWORD' );

Set Database Host

Most of the time, your hosting provider will ask you set it as a “localhost” but in many cases, there are different values associated with it. Better to ask them for this info.

Add this line of code in your wp-config.php file to set your WordPress MySQL database name.

Add your database host instead of DATABASE_HOST.


define( 'DB_HOST', 'DATABASE_HOST' );

Apart from that line of code, you might need to add a port number or Unix socket file path to setup a database host.


Most Read

#1 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
What is DevOps?MiscellaneousHow to merge arrays in JavaScript?JavaScriptWhat are Web services?MiscellaneousHow to convert an object from API to JSON array in Angular 9?AngularOOP, Class and Objects Strategies For Beginners (PHP)PHPHow to vertically align a html radio button to it’s label?CSS