In the event of a problem, such as corruption of data, or loss of the database, it may be necessary to restore your database. This is known as importing.
Importing is the process of putting copy back into a database. This is also known as restoring.
You will need your username and password for accessing your database in your control panel. Depending on your hosting you may need your username and password for the database.
IMPORTING:
- Login to your hosting and navigate to your cPanel®.
- Locate your phpMyAdmin.
- Click the phpMyAdmin button to open. You will see a screen as follows:
- Select your database
The database in this case is being indicated by the arrow.
- Once you click on your database if it contains tables and rows, you will see a number next to it and all the tables on the left side of your screen.
In our case, we have a new (empty) database and we see:
- You will see a message (not shown in image) that states No tables found in database, and the count next to the database name is zero (0).
This database is now ready for IMPORT of the data from the EXPORT step.
- Click the Import button found on the top toolbar.
The IMPORT function will display a simple screen as follows. Please note, for publishing purposes, this is a partial screenshot:
It is important unless otherwise directed, to accept the defaults for this screen.
- Click the Browse…button in the previous screenshot.
You will be presented with a dialog box such as this one. Find the location of your EXPORTED dump file from the previous recipe and choose it, then move to the next step.
- Click the Go button in the lower right-hand corner.
The database IMPORT will commence and should only take a few seconds.
Once done you should see a screen similar to the following one. The key thought you need to know is the number of records. In our EXPORT, we had forty-six records. As you can see in the following screenshot we have the same amount. Making sure the numbers are the same is important.
- This completes our IMPORT operation.
The IMPORT function works by giving the database several commands, such as the following:
INSERT INTO `jos_components` ( `id`, `name`, `link`, `menuid`, `parent`, `admin_menu_link`, `admin_menu_alt`, `option`, `ordering`, `admin_menu_img`, `iscore`, `params`, `enabled`) VALUES ( 1, 'Banners', '', 0, 0, '', 'Banner Management', 'com_banners', 0, 'js/ThemeOffice/component.png', 0, 'track_impressions=0\ntrack_clicks=0\ntag_prefix=\n\n', 1);
This tells the database to "insert" or write into the TABLE jos_components columns, the data that follows the VALUES key word.
In the IMPORT process (depending on our EXPORT settings) it will execute any other commands it finds in your .sql
file.
Another example:
CREATE TABLE IF NOT EXISTS `jos_bannertrack` ( `track_date` date NOT NULL, `track_type` int(10) unsigned NOT NULL, `banner_id` int(10) unsigned NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
The command CREATE TABLE IF NOT EXISTS jos_bannertrack
instructs the database server to create a new table called jos_bannertrack. Insert would be used to put content into the table.
The great thing for restore is the .sql
file will contain the proper commands to rebuild the heart of your Joomla! site, which is the database.