I recently done an Activity to rename 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’ walk through.
When I open my mail Inbox, I have received an e-mail from one of the Customer; I opened the e-mail & started reading it. I felt it is challenging Task; and also I am excited. Here is the requirement I have received.
“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 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 Customer’s happy face. 🙂
Now I will give the STEPS here, how I modified cPanel Account Username; with WordPress site is already installed.
STEP 1. First step is to do the pre-study to identify the impact, if we modify 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 containing Username is “.htaccess” file. There may be rules defined in this file which will use the Paths containing the Username. Note: There may be many places where these kind 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 needs 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 WordPress site which is installed. So I continued my analysis related to WordPress site.
- Most important thing for the site is its’ Database & the user credentials. We already notices that, Database & Database Usernames are prefixed with cPanel Account Usernames. If we change the Username of cPanel Account; new Database & Database Username would be “newuser_dbname” & “newuser_dbusername”.
- One of the important file, we need to look when we do these changes for WordPress site is, its’ configuration file; which is “wp_config.php” file.
- Also verify any Plugins using the configurations or Database User credentials. These can be modified to complete this Username changes.
STEP 3. I have done the pre-study for cPanel changes & WordPress site changes. I have noted all the affected areas; and 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 PRODUCTION environment is TAKE 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 the access to this from my Client. Below are the steps to modify this:
- Login into WHM.
- Click on List Account item. WHM will display of the List of Accounts.
- Choose the cPanel Account for which you would like to change the Username. That means, click on “+” 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 allows to modify the data.
- Under Basic Information section, change the Username in the Username field.
- Click on 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 file also.? No. We need to do these changes. Next STEPS will cover this.
STEP 5. Before we do the changes for 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 changes these through 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 already taken the Database back-up. Without back-up don’t attempt these changes.
Lets’ start the changes for WordPress site.
STEP 6. I was looking for “wp_config.php” file. But I couldn’t find this under “public_html” location. I understood that, this file is moved to non-accessible (to the users) location for the security reason. I found this under “/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
/** MySQL database username */
- Change the entries with 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 “.htaccess” file and change the old user name entries with new Username.
STEP 8. Lets’ verify whether the changes in all relevant places are done.
- Look at Home Directory entry. Now it is showing “/home/newuser”. Thats’ good. 🙂
- Verify the FTP Accounts. I can see these now are having path with new Username. But keep this 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 exists.
- Re-verify whether proper details are provided in “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 to you. Don’t hesitate share your feedback in below comments section.