Pankaj Sanam
Slashism

Follow

Slashism

Follow
Import Export SQL file using the command line

Import Export SQL file using the command line

Pankaj Sanam's photo
Pankaj Sanam
·Apr 19, 2020·

1 min read

Play this article

I always forget this so I'm going to save it here. This way I can import the SQL files directly in the terminal.

The following command will import the database:

mysql -u username -p database_name < /file_path/file_name.sql

The above command does not import the triggers and procedures by default.

Use -R and --triggers flags to import the routines and triggers.

Export MySQL database with the below command:

mysqldump -u username -p database_name > /file_path/file_name.sql

Thank you for reading!

 
Share this