Importing database in MySQL using command line
Importing a database in MySQL is quick & easy using the command line.
Mark van Eijk 1 minute read Databases
Different options
Importing a MySQL database can be done in several ways, using a desktop app or even using the legendary phpMyAdmin!
But the most effective and fast way to import a (large) SQL file remains - as always - using the command line interface (CLI).
Using the command line
Using the command below you can import large SQL files in the least amount of time:
mysql -u [username] -p [database] < import.sql
Replace [username], [database] and import.sql with the correct values in your setup.
To go the other way, see exporting a database. If timestamps shift on import, fix the timezone difference. And to rename a database afterwards, see rename a MySQL database.