How to change Joomla Database Prefix to Improve Security

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

go-to-joomla-global-configuration

Then click the Server Tab and find the group of settings called "Database Settings" at the right part of your screen.

joomla-database-settings

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.

joomla-configuration-php

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!';

joomla-database-prefix

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

  1. Login to your database via phpMyAdmin.

  2. Check all the tables of your Joomla! database.

    phpmyadmin-check-all-tables

  3. In the selectbox right next to the check all option, select "Replace table prefix"

    phpmyadmin-replace-table-prefix

  4. Type the current database prefix in the "From" field.

    phpmyadmin-new-and-old-prefix

  5. Type the new database prefix in the "To" field. Make sure that it ends with an underscore.

  6. Click "Submit".

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!

About the Author
Joomla Author Editorial Staff

Editorial Staff

Editorial Staff at JoomlaBeginner is a team of Joomla experts led by Tassos Marinos. Contact us if you want to join our team. Follow us on Twitter or Facebook.
Sign up to our Joomla Newsletter
Get awesome content delivered straight to your inbox twice a month

Comments

Powered by EngageBox