Rename default WordPress Database Name and Database user name one of the important security steps. If you follow WordPress auto installation method such as fantastico method, it will generate default names for database name and user. As a result of that anyone can easily guess it. However with the help of cPanel PHPMyAdmin we can easily rename them. This method will not wipe anything on your site.
After renamed WordPress MySQL Database Name And User Name we need to re-configure those details on wp-config.php file and re-authenticate user permission. Otherwise it will gives error establishing connection to the database with or without “We were able to connect to the database server (which means your username and password is okay) but not able to select the (username)_WordPress database” with “Does the user (username) have permission to use the (username)_WordPress database?“.
In order to follow my this tutorial your cPanel should available PHPMyAdmin script. Apart from that, it’s better make a backup. Because database contains all the useful information, posts, comments, user information. In case if anything goes wrong, it will affect your site and sometime your site can go offline.
This tutorial will not change the MySQL table prefix. If you need to change them, you can follow rename WordPress database table prefix tutorial.
Rename WordPress database and user is a highly dangerous procedure. If anything goes wrong, your site can completely destroy. Specially your blog posts, comments, user information. Therefore first make a database backup.
Rename WordPress database name and database user name.
Rename the database name.
- Log-in to your cPanel account.
- Then navigate to the “Databases” category.
- Next click on the “phpMyAdmin” link. Now it will open in a new tab.
- Click the top navigation menu “Operation” tab, just like the following screenshot.
- Under the “Rename Database to”, type your cPanel user name, then add an underscore symbol (_ ) after that add unique letters with few numbers for your new database name. For an instance “<cPanel user name here
- To apply change click “Go”.
- Within a few seconds, you can see a confirmation message.
- Now database renames completed. Next we have to grant the permission to access database user.
Rename database user.
- Go to “MySQL Database”.
- Then under the “Add New User”, type new user name. Then use its “password generator” create a strong password. Copy that password in a text file.
- To complete the process click “Create user” button.
- Then you have to grant the permission using the following steps.
Grant the permission to read renamed Database to new and existing user.
- Go to cPanel “MySQL Database”.
- Under the “Add User To Database” select your new database and user.
- Click “Add” button.
- Then click on the new user name.
- Next page, choose all the available options and click “Make Changes”.
- Now almost completed.
- Next we need to copy this information in your WordPress WP-config. PHP file.
Edit wp-config.php file.
After renaming step completed, we have to submit new information to WordPress. Otherwise it will give error.
- In cPanel go to “Files>File manager.
- Next flash menu click “Go”.
- Then browse the “wp-config.php” file.
- Right click on that file and choose “edit”.
- In a new tab, wp-config file will open. Search following lines and add your new details.
define(‘DB_NAME’, new name here‘);
define(‘DB_USER’, ‘new user name here‘);
define(‘DB_PASSWORD’, ‘new password here‘);
- Save the file.
- Congratulation, you have just renamed WordPress database name and user name.