Export your mysql database using the terminal

Are you moving your database to a new server or do you just need a backup? In both cases this example will come in handy.

Step 1:
Open up a terminal on the computer where the database is located or connect to it using SSH.

Step 2:
With the active directory being the folder where you want your export file to be saved, type in:

mysqldump -u {username} -p {database name} > {export file name}.sql

where you change {username}, {database name} and {export file name} with the information for your database. The {export file name} can be whatever you like to name the file that the export generates.

Hit enter and wait for the dump to finish.

You can now take the .sql file and use it for whatever you like.

If you are interested in automating this process, take a look at my post about setting up auto backup of your MySQL database.

Daniel Stryhn

Leave a Reply