Slashism

Slashism

Import Export SQL file using the command line

Import Export SQL file using the command line

Subscribe to my newsletter and never miss my upcoming articles

Listen to 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

Impressum

🙋‍♂️ Hello there,

My name is Pankaj, and I am the author of Slashism. I hope that you learn something useful today.

If you like my content and want to stay updated then subscribe to my newsletter in the header.

You can also follow me on Twitter and say hello.

If you would like to request a particular article/topic covered or would want to discuss something, then please start a discussion here on Github Discussions

⭐ Keep learning, keep growing ⭐

Proudly part of