Exporting and Importing MySQL Databases Using phpMyAdmin

It has been a long time since my last post but I have been pretty busy, sorry for that 🙂

Recently, I felt the need to export my MySQL database from one development machine and import it into another along with my PHP code. No need to mention copying the code since that is the easiest task. Copying your DB is also a simple one, but I wanted to mention it in this post for the beginners.

export-import

First, you need to export your database from the first machine so that you can import it in your second machine. Here are the steps:

Launch your phpMyAdmin instance

Click the database that you want to export (on the DBs tree on the left) and click Export button on the top

export-button-phpmyadmin

A window for export settings will open. For the beginners, you can use “Quick” settings with SQL format and just hit the “Go” button below

phpmyadmin-EXPORT window

This will export an SQL query as a .sql file which will be used to create your database tables and fill them with your existing data. You will be importing this .sql file from the second machine.

Now go to your second machine

Click “New” on the databases tree on the left (see below)

phpmyadmin-databases-tree

Give a name to your database (I suggest you give the same name as in your first machine)

Select a collation (use the same collation as in the database on your first machine)

Click “Create”

phpmyadmin-create-database

After creating your brand new empty database click it on the DB tree on the left, and click “Import” button on the top

On the window that opens you will see a section as below. Click “Choose File” and select your exported .sql file

phpmyadmin-import-sql

You don’t need to change any settings if you have used the default settings while exporting the file. Now just hit “Go”. You will see a success message and your newly created tables will immediately be available in the DB tree view on the left. If you click your tables you will see that your existing data also has been filled in on your new database.

Hope this helps.

Good Luck,
Serdar

Leave a Reply

Your email address will not be published. Required fields are marked *