How to Export MySQL Database (Command Line) to a File

Let's cut to the chase.

Open up your terminal, and type in the following command:


mysqldump --add-drop-table -u admin -p dbname > dbname.sql

Enter your password in the prompt and press enter.

Replace the following with your relevant information:
admin --> Your username
dbname --> Your database name
dbname.sql --> The name you want to give the exported file.

If all goes well, you'll have an sql file inside whatever directory you invoked the command.
Note that when you import this file inside another database, it will drop and replace the tables in the database. If you just want the data to be merged, then omit the --add-drop-table parameter from the command above.

That's all! 👦

Comments

Popular posts from this blog

How to set up Allegro 5 Library for Android Development

Assembly Language Tutorial For Beginners Part 1