I recently did an Activity to rename the cPanel Account’s Username. It is not so easy to do this if we simply rename the Username; the website which is already installed in cPanel Account, may not work as expected. This is the challenging thing. We need to consider so many things before we rename the cPanel Account’s Username.
I did this recently and would like to share the knowledge through this Article. Lets’ walkthrough.
When I open my mail Inbox, I have received an e-mail from one of the Customers; I opened the e-mail & started reading it. I felt it is a challenging task; and also I am excited. Here is the requirement I have received.
Business Requirement:
“We would like to modify one of our cPanel’s Account with more meaningful Username. We already have one WordPress site installed on this cPanel Account. Ensuring that this Username change should not affect the currently running WordPress site. We need a solution for this as early as possible.”
I felt good after reading the requirement from the Client. And I felt it is a little bit challenging. So, I took it seriously and complete the requested Activity within the time. And it is working fine as expected. I can see the Customer’s happy face. 🙂
Now I will give the STEPS here, how I modified the cPanel Account Username; with WordPress site is already installed.
STEP 1. The first step is to do the pre-study to identify the impact if we modify the cPanel Account’s Username. Why this pre-study is required.? It is required; because it is required to know what would be the impact to the Account and specifically, would need to understand, how the installed website will behave (here it is WordPress), once the Username is changed.
- When we change the Username the current Home Directory will change. For example: if the Username is “olduser”, the home directory would be “/home/olduser”. Once you change the Username to “newuser”, the Home Directory would be “/home/newuser”.
- FTP Accounts paths will have this Username and once we change it; these paths will change. That means, if you have already configured the FTP Client from your Desktop / Laptop to access this FTP Account, you need to re-configure the FTP Client; because the FTP Paths are changed; due to the Username change. For example: If the existing FTP Path is pointing to “/home/olduser/path” will become “/home/newuser/path” after the Username change.
- Another place where you can see the Paths may contain Username is the “.htaccess” file. There may be rules defined in this file that will use the Paths containing the Username. Note:Â There may be many places where these kinds of dependencies you can see, but these are the common places where people modify the entries. Depending on the complexity of the Website you have; the files/paths where these changes happen will change.
- Look at the Databases created. And the Database Users. Mostly these will prefix with the Username. For example The Database name “dbname” prefix with “olduser” would be “olduser_dbname” & the Database User would be “olduser_dbusername”. These need to be changed with special precautions; because these are the names your Website is using; and if you simply modify these without caution, your Website will STOP working.
STEP 2. Now continue the analysis for the Website installed on the cPanel Account. In this case, this is the WordPress site that is installed. So I continued my analysis related to the WordPress site.
- The most important thing for the site is its’ Database & user credentials. We already notices that Database & Database Usernames are prefixed with cPanel Account Usernames. If we change the Username of the cPanel Account; the new Database & Database Username would be “newuser_dbname” & “newuser_dbusername”.
- One of the important files, we need to look at when we do these changes for the WordPress site is its’ configuration file; which is the “wp_config.php” file.
- Also, verify any Plugins using the configurations or Database User credentials. These can be modified to complete these Username changes.
STEP 3. I have done the pre-study for cPanel changes & WordPress site changes. I have noted all the affected areas; now I know what are the impacts if we change the cPanel Username. Now its’ time to do the changes.
One VERY IMPORTANT thing you need to remember before making any changes in the PRODUCTION environment is to TAKE BACKUP.
- Take Complete Website backup. This link may be helpful: “cPanel: Generate “Full Backups” using Backups page”
- Go to phpMyAdmin and Export the Database. This step is to take Database backup.
Store these backup files into the secured area and these can be used to restore the changes if something went wrong with our changes.
STEP 4. Now start doing the changes. We can do the cPanel Account’s Username change through WHM Control Panel. I got access to this from my Client. Below are the steps to modify this:
- Login into WHM.
- Click on the List Account item. WHM will display the List of Accounts.
- Choose the cPanel Account for which you would like to change the Username. That means, click on the “+” symbol which is at the Account name. WHM will expand and display the options to modify the Account.
- Click on Modify Account button. WHM will display Account Information and allow to modify the data.
- Under the Basic Information section, change the username in the Username field.
- Click on the Save button, once done the changes.
WHM will change cPanel’s Username wherever required and wherever it is referencing.
Does it change the entries in WordPress sites’ configuration files also.? No. We need to do these changes. Next STEPS will cover this.
STEP 5. Before we do the changes to the WordPress site, verify whether Database & Database Usernames are changed. Usually, WHM will change the “prefix” it. If you want to change these names (we can’t change the prefixes); you can change these through the below steps:
- Use cPanel’s “MySQL® Databases”, to rename the Database name & Database User name.
- cPanel will prompt the warning message when you attempt to rename these; you can continue the rename, as you have already taken the Database back-up. Without backup don’t attempt these changes.
Lets’ start the changes for the WordPress site.
STEP 6. I was looking for the “wp_config.php” file. But I couldn’t find this under the “public_html” location. I understood that this file is moved to a non-accessible (to the users) location for security reason. I found this under the “/home/newuser” location, which is not accessible to the Users.
- Open the “wp_config.php” file in Code Editor. When I open it, I can see below are the entries where changes are required:
/** The name of the database for WordPress */
define( 'WPCACHEHOME', '/home/olduser/public_html/wp-content/plugins/wp-super-cache/' ); //Added by WP-Cache Manager
define('WP_CACHE', true); //Added by WP-Cache Manager
define('DB_NAME', 'olduser_db');
/** MySQL database username */
define('DB_USER', 'olduser_usr');
- Change the entries with a new Username. Ensure, you give the correct Database name & Database Username. Otherwise, your WebSite won’t work as expected.
- Save the changes once done.
STEP 7. Open the “.htaccess” file and change the old user name entries with a new Username.
STEP 8. Lets’ verify whether the changes in all relevant places are done.
- Look at the Home Directory entry. Now it is showing “/home/newuser”. Thats’ good. 🙂
- Verify the FTP Accounts. I can see these now are having paths with the new Username. But keep in mind that; if you already configured this FTP Account to access from FTP Client; you need to re-configure it to point to the Right Path.
- Check the Database & Database Usernames are correctly defined.
- Open phpMyAdmin and access the Database. I can see Database & Database Tables exist.
- Re-verify whether proper details are provided in the “wp_config.php” file. If the details are not proper, your WebSite will fail to access the Database and it may through the below error:
Error establishing a database connection
- Verify “.htaccess” entries are updated properly.
STEP 9. Now, access the WebSite. Hurray!!!!!!!! The WebSite is working fine as expected.
After completion of this; I felt happy, after seeing the WebSite is working. And I can see MY CLIENT’S HAPPY FACE too. 🙂
I hope this article helps you. Don’t hesitate to share your feedback in below comments section.
Happy reading!
Regards,
Bela