Knowledge
Importing database in MySQL using command line
#Databases
Importing a database in MySQL is quick & easy using the command line.
Published by Mark van Eijk on August 30, 2022 · 1 minute read
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.
Subscribe to our newsletter
Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!
More in #Databases
- Stream MySQL backup directly to S3 bucket
- Export MySQL database using command line
- How to upgrade MySQL 5.7 to 8.0 on Ubuntu
- Backup MySQL databases in separate files
- Backup MySQL databases in single file
- Backup MySQL databases except system databases in a single file