skip to content
Slashism

Import and Export SQL files using terminal

/ 1 min read

Keeping it here, just in case I need it again. It’s a simple command but my brain is too lazy to bother memorizing it. I know it’s not good, but it is what it is 🤷‍️

Import your DB by using below command (use -R and --triggers flags if you want to import triggers and procedures as well):

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

Export your MySQL database with the below command:

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