Using PhpMyAdmin Export and Import MySQL Data
phpMyAdmin is a popular
and free PHP application used for administering one or more MySQL servers. Although this instruction focuses
on Windows XP(IIS), you may find helpful hints for setting phpMyAdmin
with Apache.
I assume you installed PHPMyAdmin
and Mysql before you start this
lesson.
It is quite often for web master to export and import data between
2 different MySQL database or backup MySQL data. PHPMyAdmin provides
us an easy tool to fulfill this task in just few clicks.
Let's assume we changed our web hosting company and need transfer
MySQL database data from old web hosting site to the new one.
Export
data from MySQL database
Suppose we have a table named textTable holding all text, numerical
data. In order to migrate this data to new MySQL database, we need
dump all data out.
Open your PhpMyAdmin control panel, select your database and your
table want to export. Then click on "Export" tab. You will the the
above image on your screen.
Check "Save as file" and type a file name in "File
name template"
text box. Then, Select "gzipped" for "Compression".
This could save you a lot of exporting time if your table is huge.
Then click on
"Go" button. You will have prompt window asking you where
to save your exporting data. You may save it to your desired directory.
In our example, you most likely will have an "texttable.sql.gz" file
saved.
The exported data more or less look like the following. It is a
collection of SQL commands.
-- phpMyAdmin SQL Dump
-- version 2.6.4-pl2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Dec 01, 2005 at 01:02 PM
-- Server version: 4.0.16
-- PHP Version: 4.3.11
--
-- Database: `testingdatabase`
--
-- --------------------------------------------------------
--
-- Table structure for table `TextTable`
--
CREATE TABLE `TextTable` (
`no` int(11) NOT NULL default '0',
`test` text,
PRIMARY KEY (`no`)
) TYPE=MyISAM;
--
-- Dumping data for table `TextTable`
--
INSERT INTO `TextTable` VALUES (1, 'tests');
INSERT INTO `TextTable` VALUES (1, 'tests2');
........
|
Import
Data to MySQL
Then PhPMyAdmin control panel in your new website, open your database
that you want put your data in. You could see the following image:
Click on "SQL" tab. Use "Browse" button located the exported data
file that is saved in step 1. You may choose "Autodetect" for "Compression".
Since we know it is a "gzipped" file, we check on "gzipped". Then
click "Go" button.
You will see your dumped table in your new site. |