How to Change the Name of Your WordPress Database in Less Than 5 Minutes

Want to change the name of your WordPress database?

If you’ve got more than one WordPress install on your server, of if you’re anything like me, you’d rather not go to your PHP My Admin and see database names that look like this:

  • wpdb14
  • wpdb15
  • wpdb17
  • wpdb18

It gets a bit tricky to keep track of things when you can’t tell which database belongs to which site. Not to mention that if you make a modification to the wrong database, you could end up having to back trac and end up creating a problem on  your live site that takes you some time to patch up.

And of course, it’s a lot easier for a hacker to guess your database name if it’s too generic, and that’s one less thing they have to figure out if they want to “do you in.” Whatever your reason is, changing the name of your WordPress database isn’t hard, you can do it in less than five minutes.

I’ll show you exactly how in this blog post. Just a few quick disclaimers first:

  1. Don’t attempt this on your live WordPress site the first time you try it. Use your testing site and make sure you’ve got the process down before making the change to your live site.
  2. Always make a backup of your WordPress database before doing this, just to be on the safe side.
  3. Your WordPress site will experience a few minutes of downtime, so you might want to redirect your domain to an “under construction, back in 5 minutes” page if you’re expecting a lot of traffic.

#Step 1: Change the Database Name in Php My Admin

Your first job is to go to your PhpMyAdmin dashboard from your C Panel of your hosting account. I use Hostgator, so this is what it looks like in my CPanel:

Most hosting companies have a similar set up to this ^ so PhpMyAdmin should be fairly easy for you to find. From there, you go to the “Operations” screen in PhpMyAdmin where you’ll see an option to change your database name. Go ahead and change the name to anything you want and make sure you put the name somewhere you can find it quickly.

Once this is done, you’ll need to change the name of your database in your WordPress configuration file so that your database and your WordPress site are communicating using the right credentials…

#Step 2: Change the Database Name in Your WP-Config File

Your WordPress configuration file will be found under the root directory of your WordPress install. It’s named “wp-config.php.” Some installations of WordPress also include an example configuration file, don’t mess with that one because it won’t impact your site.

Here’s a screen shot of me highlighting the “wp-config.php” file in the root directory of my WordPress testing site. Once you find that file, click on the “edit file” option and the file will open up in a basic text editor:

If you really want to be on the safe side, make a quick backup of your “wp-config.php file before you make any changes to. Once that’s done, look for the three lines of code which define your database name, username and password, it will look like this:

(I’ve whited them out in this example for obvious reasons):

You’ll notice here ^ that there are also options for changing your WordPress database password and username. This is optional, but if you decide to change them, just make sure you go to the dashboard for your MySQL databases and add the new username and the updated password as well.

(I suggest you avoid this unless you feel that the login information for your WordPress database has been compromised)

Once you’ve saved those changes in your “wp-config.php” file, go back to your WordPress site and reload it into your browser. It should look just like it did before you made the database name change. If not, go back and double check yourself on each of these steps because you probably missed a detail somewhere.

You can use this same strategy to change your WordPress database name as many times, or as frequently as you need to. Just be sure to do a few trial runs on your testing site and build up some confidence before you try this on your main site.

Any problems or questions, post your input below.


Seth C