Tuesday, February 5, 2019

How to take MySQL dump using the command utility "mysqldump"

This post discusses about taking backup of your database using the utility "mysqldump"

This post assumes you have MySQL Server installed, up and running

Alright, lets talk the business..

There are two ways you can have the MySQL Dump one is with data and another is without it

this post provides options for both, depending on you requirement you can pick the appropriate

Taking MySQL Server Database Dump with data

This form takes the format as mentioned below
mysqldump --routines --add-drop-table --disable-keys --extended-insert --host=<SERVERHOST> --port=<PORT> --user=<USERNAME> --verbose <DATABASENAME> --password > <FILENAME>.<EXTENSION>

let us assume certain parameters to this utility as follows
--host=localhost
--port=3306
--user=root
<DATABASENAME>=mysql
<FILENAME>=serverdump-of-database-mysql
<EXTENSION>=sql
for the above mentioned parameters, the command appears to be as follows...

mysqldump --routines --add-drop-table --disable-keys --extended-insert --host=localhost --port=3306 --user=root --verbose mysql --password > serverdump-of-database-mysql.sql

Now open a termial window and fire the command at the prompt as follows
> mysqldump --routines --add-drop-table --disable-keys --extended-insert --host=localhost --port=3306 --user=root --verbose mysql --password > serverdump-of-database-mysql.sql
at the end of the process you should be having the file "serverdump-of-database-mysql.sql" at the present-working-directory.

that is it, you have backed up your required database successfully...

Taking MySQL Server Database Dump without data

This form takes the format as the one we discussed above but with a little difference...
mysqldump --routines --add-drop-table --disable-keys --extended-insert --host=<SERVERHOST> --port=<PORT> --user=<USERNAME> --verbose <DATABASENAME> --no-data --password > <FILENAME>.<EXTENSION>

having the same parameters as discussed above the command appears to be...
mysqldump --routines --add-drop-table --disable-keys --extended-insert --host=localhost --port=3306 --user=root --verbose --no-data mysql --password > serverdump-of-database-mysql.sql

now fire the command at the prompt as given below
> mysqldump --routines --add-drop-table --disable-keys --extended-insert --host=localhost --port=3306 --user=root --verbose --no-data mysql --password > serverdump-of-database-mysql.sql

well that is it you have taken the structure or template of the requierd database.

No comments:

Post a Comment

Addressing Modes of 8080 / 8085 MicroProcessor

Hi,   In this post I am going to talk about different addressing modes of 8080/8085...without much talking let us get into the topic.   Ther...