Tuesday, April 15, 2008

How to Import .SQL Dump File into MySQL

This tutorial goes through the steps of how to import a SQL script file into a MySQL database. The computer setup I'm using for this step-by-step guide includes Windows XP Professional and MySQL 5.0, however you should also be able to use this same process for importing SQL dump files with MySQL 4.1.

1. Open the MySQL Command Line Client and type in your password, and press Enter to login. See Figure 1.

2. Change to the database you want to use for importing the .sql file data into. Do this by typing

USE your_database_name

and press Enter. See Figure 2.

For example the full line would look like: mysql> USE myTestDatabase

3. Now locate the .sql file you want to execute. For instance if the file is located in the main local C: drive directory and the .sql script file name is currentSqlTable.sql, (See Figure 3) you would type the following:

\. C:\currentSqlTable.sql

and press Enter to execute the sql script file.

For example, the full line would look like: mysql> \. C:\ currentSqlTable.sql

Note: You can use either the source or \. command to execute a SQL script file. For instance:

mysql> source file_name
mysql> \. file_name

8 comments:

D said...
This comment has been removed by the author.
bikcmp said...

Thank you so much! I tried 5 tutorials but only this works! Thanks again!!!

Unknown said...

great. thank you from the bottom of my heart. I checked so many sites for this simple explanation and this is really simple explained and it FINALY worked.
Thanks again

eskodisko said...

top! agree to the above, gah really need to brush up on some sql usage.

thank you

Unknown said...

Very concise and simple. Thank you! My heart filled with happiness to see over half a million records integrated in less than 5 mins.

Unknown said...

I cant see any of the pictures.

MikeBCh said...

Wow, thanks a lot. Finally something worked.
Really. I tried several things they suggested in other sites.
Thanks a lot again.

Tapan said...

many many thanks :)