How to Import .SQL Dump File into a MySQL database
Execute SQL Statements from a SQL script file with the MySQL Command Line Client.
Updated January 29, 2009
Open the MySQL Command Line Client and enter your password.
At the mysql command line type: USE your_db_name to change to the database you want to use for importing a SQL script file into.
Type in the mysql source or \. command, followed by the location of your script file to execute it against your database.
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
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:
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