Quick command line MYSQL backup or copy your mysql database

Just a quick note on how to backup or copy your database through the command line.

First thing you need is a sql dump of your database :-

Show Plain Text
Text code
  1. mysqldump --add-drop-table -h <hostname -u <user_name> -p <database_name> > database_name.sql

Now login to your mysql :-

Show Plain Text
Text code
  1. mysql -h <hostname> -u <user_name> -p

Now create your new database :-

Show Plain Text
Text code
  1. create new_database;

Now copy your data to the new database :-

Show Plain Text
Text code
  1. use new_database;
  2. source database_name.sql;

Job done

Filed under: Notes  Tags: Mysql

0 Responses to “Quick command line MYSQL backup or copy your mysql database”

Sorry, comments have been closed for this post.