Mysql useful commands

### Mysql dump ###


== Syntax global == 
mysqldump [options] db_name [tables]
== Syntax to backup only one database == 
mysqldump -u [username]  -p [password] [database_name] > [backup_file.sql]
== Syntax to backup multiple databases ==
mysqldump -u [username]  -p [password] –databases [database_names] > [backup_file.sql]
== Syntax to restore databases ==
mysqldump -u [username]  -p [password] [database_to_restore] < [backup_file.sql]
ex. [Only one database]
mysqldump -uroot -ppassword database_name > file_name
ex. [Multiple databases]
mysqldump -uroot -ppassword –databases database_name1 database_name2 > file_name
Advertisements