Which Joomla File Is the Database?

Every other week or so, we get a call from a (potential) client that goes like this:

Client: “Hi!”
Us: “Hi!”https://www.itoctopus.com/wp-admin/post.php?action=edit&post=1329&message=1
Client: “I would like to make some edits to my database, and I want to know which Joomla file is the database.”
Us: “Well sir, the database is not stored in any Joomla file, the database is (usually) MySQL database – Joomla just connects to this database.”

The above conversation is typical, there is a misconception that there is a Joomla file where all the data is stored, which is not the case. In this post, we will explain where is the Joomla database, and what are the two main Joomla files used to connect and interact with the database.

Where is the Joomla database?

The Joomla database exists on usually a MySQL server, the name of the database is declared in your configuration.php file. In order to view your Joomla database, you will need to do the following:

  • Login to your cPanel account.
  • Go to your phpMyAdmin in cPanel (there should be a phpMyAdmin icon somewhere in the middle of your cPanel home screen).
  • Locate the name of your database (which is declared in the $db variable in your configuration.php file) and click on it (in phpMyAdmin).
  • Now you can view all the tables in your database (you can click on any table to view its contents). Your data is stored in these tables, for example, your articles are stored in jos_content, and your users are stored in jos_users.

What are the two main files that are used to connect to your Joomla database?

Joomla mainly uses 2 files (of course, there are many supporting files, but these two are the main ones) to connect to your database and to interact with your database:

  1. configuration.php: This file is located under the root directory of your Joomla website. It contains the connection parameters to your database, specifically:
    • The type of the database: The type of the database is usually mysql, and it is stored in the $db_type variable.
    • The name of the database: This is the name of the database storing the data for your Joomla website. The database name is stored in the $db variable.
    • The table prefix: Also known as database/table alias, the table prefix defines what prefix should be appended to your Joomla tables in the database. The table prefix is defaulted to jos_, that’s why in the Joomla database, you have tables such as jos_categories instead of just categories. The table prefix is defined by the $table_prefix variable. The table prefix is useful in case you have multiple websites powered by the same database (and you don’t need to have conflicts between the tables). It is also very useful for security (it will be hard to guess your table name if you change the table prefix. (see 10 Security Tips for Your Joomla Website).
    • The database user: The username that is used to connect to your Joomla database. It is stored in the $user variable.
    • The user’s password: This is the password of the user above. It is stored in the $password variable.

    Now, we have all the connection parameters to the database, but how do we connect to the database and get data? Well, that’s the job of database.php!

  2. database.php: This file is located under this folder: /yourjoomlawebsite/libraries/joomla/database/, and it is responsible for connecting to the database (by using the connection parameters in configuration.php), getting data from your database, and inserting/modifying/deleting data in your database.

    The database.php file contains a class called JDatabase that contains all the methods needed to interact with your database. Note that you should never change the database.php file. Doing so may leave your website non-operational.

If you have problems with your Joomla database and you need help, then that why we’re here for! Just contact us and we’ll do our best to help you! We’re also very fun to work with!

2 Responses to “Which Joomla File Is the Database?”
  1. Comment by Takashi Koyama — March 31, 2015 @ 5:09 pm

    Hello, I was asked by my manager to copy the Joomla site’s database files onto a DVD.

    Where can I find the files? Where is the folder? I assume it’s something like C:\..\mysql\..\

    I opened the configuration.php but I could not find the path in the window server. Please help me on this.

    Thank you.

  2. Comment by Fadi — April 2, 2015 @ 10:38 am

    Hi Takashi,

    You can always export the database using phpMyAdmin even if you’re using Windows. Typically, your host has phpMyAdmin installed so you can login to your hosting account and download it from there. Once downloaded, you can copy to a DVD.

    If this is an in-house server then you can just install phpMyAdmin (you can download it by Googling “download phpMyAdmin”), configure it (it literally takes 5 minutes) using the same db configuration settings found in your configuration.php file, export the database, and then uninstall it (uninstall phpMyAdmin).

Leave a comment