How do I connect a new Joomla install to an old Database.

Published in Joomla


 How do I connect a new Joomla install to an old Joomla Database

Today I installed a new Joomla 3.0 site and connected it to an old Joomla 3.0 database. Thanks to errors on a site, I ended up only with the mysql database and no joomla file installed on the server. I wanted to install the latest version of Joomla and point it to the old database. It wasn't straightforward, but it was easy. Heres how you do it. (Note: This will probably work with Joomla 2.5 but I haven't tested it). Update: I have connected a NEW Joomla install to and OLD Joomla 2.5 database and it worked! - but only after I logged in and used the "FIX Databse" button in Joomla 3 (nder "Extensions manager - Database tab).


As always, before you play around with you valuable data, make sure you have a backup!

NOTE: DO NOT try to connect the installation process to your old database. This won't work and worse it could wipe over the data in your database. Install read these steps and follow them once you are ready.:

1) Install Joomla using the option to create a NEW database (don't worry about what you call it, you're only going to delete it soon anyway - I called it "deleteme").
2) Once you have installed Joomla using a new emptey database find the files on you web server in the root (base directory) of you Joomla install and edit the file "configuration.php" in a text editor.

Look for the following code:

  • public $host = 'localhost';    <<Put the host address of old database between the ' ' - it's probably the same host.
  • public $user = 'database user';     <<Put the NAME OF THE USER of your old Joomla database here
  • public $password = 'password';     <<Put the PASSWORD for you old Joomla database here
  • public $db = 'database name';    <<Put the NAME of the old database here
  • public $dbprefix = 'joomlaprefix_';  <<<This one is super important. Here you have to put the prefix which was generated during the installation of the OLD Joomla site. You can easily copy and past this prefix from the old configuration.php if you still have a backup of that. If you don't you will have to log on to your hosting control panel and use phpmyadmin to open the old database. You will see that all the tables in the old database are prefixed (they have some text in the front of every table), copy and past the prefix in here in your new configuration.php

If you correctly updated the configuration.php on your new joomlasite with the access details from the old database the new Joomla site will now connect and display all the content from the old database.

Be aware that connecting a new Joomla install to and old Joomla site could create all kinds of errors. Especailly if you had modules installed on the old site that aren't on the new one. You are recommended to test your site thoroughly. Most notable will be plugins and templates which are missing. Start by reinstalling all the same add on components, templates and plugins the old site had and configuring them and then delete any other plugins or components which you no longer need and might be causing errors. Even if you don't need them, installing and then uninstalling plugins can be an easy way of eliminating unwanted components that no longer work and don't uninstall because the files no longer exist on the server.

Good luck!