You are on page 1of 3

Exporting a database with PHPMyAdmin

Last modified: January 27, 2010

With regard to the instruction below: leave the checkboxes as they are if already selected or set if needed.

Using your web browser,


1. Go to the PHPMyAdmin location of the server where the database you wish to export resides. For example: http://www.example.com/phpmyadmin/ for a remote database and http://localhost/phpmyadmin/for a database hosted on your Apache2Triad installation. Select the name of the database you wish to export from the combo box on the left side of the page and you will be taken to that database's main operations page. 2. Click the tab labeled "Export" and you will be taken to the Export database page. 3. In the EXPORT group, select the check box: o Select the check box marked "select all" to select all of the tables in the database for export. o The radio button selected below should be "SQL". 4. Within the OPTIONS group; under the STRUCTURE sub group, o Select the check box next to "Structure" o Select the check box labeled "add DROP TABLE"* o Select the check box labeled "Add AUTO_INCREMENT value" o Select the check box labeled "Enclose table and field names with backquotes" 5. Within the OPTIONS group, under the DATA sub group: o Select the check box marked "Complete inserts". o Select the check box labeled "Use hexadecimal for binary fields" may be selected o Select "INSERT" in the combo box labeled "Export type:" 6. Below, select the check box labeled "Save as file" group, 7. then type a name for the database and 8. click the button labeled "Go". 9. Select a location to save your database to (preferably something easy to remember, like the database folder of your Drupal installation in htdocs, for example). ***IMPORTANT*** Selecting "add DROP TABLE" means that if the copy of the database created is later imported to another Drupal installation, the tables in the imported copy will overwrite them if they exist in the target database. You should be careful to keep track of your databases, and make sure you only import and export the correct databases for your task! Note if a radio button other than "None" is enabled in the group "compression". Uncompressed databases may be larger, but are sometimes easier to work with. This document details that items that should be selected. If it is not in this document above, then it *should/can* be omitted.

Finally, it cannot be stressed enough how important it is to make a backup of both your server files and you database! DO NOT DELETE a database or files off a server unless you are 200% sure that everything works! For our visual thinkers, here is a screenshot of the above :) http://www.johnvsc.com/files/phpMyAdmin-screenshot.jpg

Importing a database with PHPMyAdmin

Last modified: June 13, 2010

1. Using your web browser, browse to the PHPMyAdmin location of the server where the database you wish to import resides. For example: http://www.example.com/phpmyadmin/ for a remote database and http://localhost/phpmyadmin/ for a database hosted on your Apache2 installation. 2. Here you will either need to select an existing database name in the combo box on the left side of the PHPMyAdmin page, or create a new one. Note that if you are setting up a database on a remotely hosted site, your host may have prohibitions on the creation of MySQL databases that require they be created outside of PHPMyAdmin by means of a control panel or other mechanism; check with your web hosting service for specific details of their requirements. 3. Once you have selected or created the appropriate database name, select the tab labeled "Import" on the PHPMyAdmin page to be taken to the import page. 4. Find the control group in the Import page form labeled "Location of the text file" and click the button labeled "Browse", following the resulting dialogs to select the database file of your choice. IMPORTANT If you are importing a database that you exported using the instructions in this tutorial, remember, the tables of the imported database will overwrite any that exist in the database you are importing to, overwriting them. Therefore it is important to doublecheck that the database you are selecting and the target you are importing to are correct before proceeding. If uncertain, you should back up the target database before importing a new one into it. 5. Click the button labeled "Go" to import your new database.

What to do if import fails - Alternate command-line import


If the import fails (maybe because of charset differences, or because it was exported using MySQLDump), you can try to import it via the command line: 1. SSH to the source unix machine and run the following command :
mysqldump -u sourceDbUser -pPassword sourceDbName > db.dmp

2. Open a CMD command-line window on the target Windows machine and run the following command:
mysql -u root -pYourApache2TriadRootPassword newDbName < db.dmp

mysqldump export to phpMyAdmin import - error

phpMyAdmin can have trouble processing the conditional comment lines of mysqldump. If you export your database using mysqldump you may receive the following error upon import:
-- MySQL dump 10.10 --- Host: localhost Database: databaseNameHere -- ------------------------------------------------------- Server version 5.0.19-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; MySQL said: Documentation #1065 - Query was empty

Then try this mysqldump command:


mysqldump -uroot -proot --compact --quick databaseNameHere > databaseNameHere.sql

This is useful for making hourly backups of your database via crontab which can be imported by your developers via phpMyAdmin.

You might also like