The quick snippet of how backup and restore MySQL database using mysqldump:
Backup: # mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql Restore: # mysql -u root -p[root_password] [database_name] < dumpfilename.sqlBackup MySQL database
1. Backup a single database:
# mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql2. Backup multiple databases:
# mysqldump -u root -p[root_password] --databases [database_1] [database_2] > database_1_and_2.sql3. Backup all the databases:
# mysqldump -u root -p[root_password] --all-databases > /tmp/all-database.sql4. Backup a specific table:
# mysqldump -u root -p[root_password] database_name table_name > /tmp/database_table.sqlRestore MySQL database
1. Restore a database
# mysql -u root -p[root_password] [database_name] < dumpfilename.sql2. Backup a local database and restore to remote server using single command:
# mysqldump -u root -p[root_password] database_name | mysql -u root -p[root_password] --host=remote-server -C database_name1
0 comments:
Post a Comment