How to change Joomla Database Username and Password
- by Editorial Staff
- on Tutorials
All of the CMS need a database to store their data. Joomla of course is no exception to this rule and in this tutorial we're going to learn how to change the database credentials because databases too have credentials.
Why do I need to change database credentials?
There are two reasons why you would need to change your database credentials.
1. Security concerns
All kinds of credentials need to be changed at set periods of time purely because of their sensitive security nature. Database credentials adhere to the same rule. Believe me when I say that you do not want be surprised by a repeatedly hacked Joomla website because your database credentials somehow got leaked under your nose sometime in the past.\
2. Change of hosting provider
A lot of hosting providers use a distinct naming scheme for databases and database users. This means that you might as well not be able to use the exact same credentials you had from your previous hosting provider and in this case you are forced to change them.
Anyhow, regardless of the reason, as far as changing security related data like the database credentials you should strive to be proactive rather than reactive.
How to change database username and password in cPanel
cPanel is the most popular Linux-based web hosting control panel that provides a graphical interface to simplify the process of hosting your Joomla website.
To change a database username and password through cPanel first you need to login to it and then navigate to MySQL Database.
Scroll down until you find the Current Users section. In this section you can click the Change Password link to be redirected to the Set MySQL User Password screen through which you can set you new password.
To change the username, you should click the Rename link. By clicking that link a modal will appear which will allow you to rename your database username.
It should be noted that there is a good chance that you might not be able to change the entire username and that is ok if you are changing it just for security reasons. However if you really need to change the entire username you should contact your hosting provider first.
How to change database username and password in Joomla
First it should be noted that you can change the database username alone through Joomla's Global Configuration but you can only do that if
- You haven't already changed it on the server
- You don't have to change the database password
If you meet both of the above requirements, navigate System > Global Configuration and click on the Server Tab. You should be able to find the Database Settings and inside it the Database Username option. Change it and click Save.
If you do not meet both of the above requirements, the only way to change both the database username and password is by directly editing the configuration.php file.
You should be able to find the configuration.php file at the root of your Joomla website through cPanel file manager or a common FTP client.
As you can see from the screenshot above you should be able to find the values for the $user variable which is the database username and the $password variable which is the database password. Go ahead and change their values and save the file to end this process.
If you liked our small tutorial about how to change Joomla's database username and password, we would be glad to have you signed up to our Newsletter or even as a follower on Twitter to keep you informed about the latest news and tutorials about Joomla!