How do I import a SQL “dump” file to MySQL?
If the file is smaller than 100 MB (uncompressed), the phpMyAdmin Web pages we provide can often be used. If it’s larger, or if you get “timeout” errors, you’ll probably need to use the MySQL command line.
On this page:
- Using phpMyAdmin
- Using the MySQL command line
- What if my “dump” file already contains a CREATE DATABASE line?
- What if I have a CSV file instead of a MySQL “dump” file?
You’ll first need to create the new, empty database on our servers using the account control panel. After the new database has been created:
- Login to the new database using phpMyAdmin
- Click the database name on the left-hand side of the page
- Select the Import tab
- Click the browse button under “File to Import”, then select the database file from your computer
- Click Go to import the database
(If you see a “No database selected” error, it’s probably because you forgot to click the database name in step 2.)
Make sure the dump file you’re importing is uncompressed. We don’t support .zip compression of dump files because we've had reports of it causing problems.
Using the MySQL command line
To use the MySQL command line, you’d first upload the dump file to your website using an FTP program, etc.
Then you’d connect to the shell using SSH. When connected, type the following command, replacing “database_name” with the actual name of the MySQL database you want to use and “filename.dump” with the name of the file you uploaded:
mysql -u database_name -p database_name < filename.dump
You will be asked to enter a password. This is the password you chose when you created the MySQL database, not your master account password.
If you need assistance with the second (shell) part of this, please contact us after you’ve uploaded the dump file using FTP. Let us know the name of the file and the name of the empty MySQL database you want to import it into. We’ll be glad to import it for you (this may take up to one business day), and there’s no charge as long as you only need this done once. If you need our assistance more than once, a fee would be involved as described on our FileFix page.
What if my “dump” file already contains a CREATE DATABASE line?
You might have problems following the instructions above if your dump file came from another system that added a line like this:
CREATE DATABASE `database_name`;
That can cause errors saying the (empty) database already exists:
ERROR 1007 (HY000): Can't create database 'database_name'; database exists
The solution to this is to first use DROP DATABASE from either phpMyAdmin or the command line:
DROP DATABASE `database_name`;
After you do that, you should be able to import the file using phpMyAdmin, or using the command line with this slightly modified command that omits the database name from the end of the command:
mysql -u database_name -p < filename.dump
(If you don’t omit the database name, you’ll get a different error telling you that the database doesn’t exist because you dropped it.)
What if I have a CSV file instead of a MySQL “dump” file?
See our page explaining how you can import a CSV (comma separated values) text file into MySQL from Excel or a similar program.
Copyright © 2000-2022 Tiger Technologies LLC