How to change Joomla Database Prefix to Improve Security
- by Editorial Staff
- on Tutorials
In this tutorial we are going to discuss a very important matter concerning your Joomla security. This matter is the database prefix, how to find it and how to change it. Let's start.
What is the Joomla database prefix?
Joomla communicates with its database using a certain naming scheme. This means that all of the Joomla database tables start with the same small set of characters which is what you call "database prefix". The reason for this naming scheme is so that you can install multiple Joomlas using the same database with the distinction of a different database prefix for each one so they are effectively separate.
This database prefix is determined at the time of the Joomla installation and by default it is the string "jos_".
Why do I need to change the Joomla database prefix?
It is strongly recommended to change your database prefix into something different than the default because otherwise it can be targeted relatively easy for malicious purposes.
As far as security goes, always be proactive than reactive.
Where can I find my Joomla database prefix?
There are 3 ways to find your database prefix.
1. Using the Joomla! Back-end (Super administrators only)
First you need to log in to your Joomla! backend and navigate to System > Global Configuration
Then click the Server Tab and find the group of settings called "Database Settings" at the right part of your screen.
As you can see there is a field called "Database Tables Prefix" which holds your current database prefix.
2. Using the file configuration.php
To find the configuration.php you need to have file access to your server. Most hosting providers will accompany an FTP service or a control panel service or even both for various administrative actions, including file access.
Use any kind of file access you feel comfortable with and find the configuration.php file at the root of your Joomla! installation.
When you open it, search for the variable "$dbprefix" which holds the value of your current database prefix.
public $dbprefix = 'jos_';
3. Using a database interface (e.g. phpMyAdmin)
Obviously this method requires access to the database via a database interface tool like phpMyAdmin. On top of that you also need the database credentials to login to the database. You can find the database username and password from the configuration.php file. Just search for the variables "$user" and "$password".
public $user = 'userjoomla'; public $password = 'r@nd0mp@ss!';
Then as you can see in the screenshot above all of the tables start with the same set of letters and they always end with an underscore. In our example the database prefix is "jos_".
How to change the database prefix
Before changing the database prefix make sure that you have your database backed up because this process is irreversible.
Now, in order to change the database prefix we need to do the following
Login to your database via phpMyAdmin.
Check all the tables of your Joomla! database.
In the selectbox right next to the check all option, select "Replace table prefix"
Type the current database prefix in the "From" field.
Type the new database prefix in the "To" field. Make sure that it ends with an underscore.
With the database prefix changed in the actual database, all that's left to do is to update our configuration.php file with the new database prefix. Just find the "$dbprefix" variable like you did previously and change its value.
That was it! If you liked our tutorial about the Joomla! database prefix go ahead and follow us on Twitter or subscribe to our Newsletter to stay up to date with our latest posts!