Backup and Restore Mysql database table

Dump and restore from .sql

Dump

mysqldump db_name table_name > table_name.sql

Restore

mysql -u <user_name> -p db_name
mysql> source <full_path>/table_name.sql

or in one line

mysql -u username -p db_name < /path/to/table_name.sql


Dump and restore from a compressed (.sql.gz) format

Dump

mysqldump db_name table_name | gzip > table_name.sql.gz

Restore

gunzip < table_name.sql.gz | mysql -u username -p db_name

 

mysqldump can take a tbl_name parameter, so that it only backups the given tables.

mysqldump -u -p yourdb yourtable > c:\backups\backup.sql

Related Posts

  • 45
    What is mysqldump The mysqldump client is a utility that performs logical backups, producing a set of SQL statements that can be run to reproduce the original schema objects, table data, or both. It dumps one or more MySQL database for backup or transfer to another SQL server. The mysqldump command can also generate output…
    Tags: dump, table, tables, mysqldump, mysql, database, format, backup, restore
  • 30
      In the backup script the views are first created as tables which are then dropped at the end of the script as each view is being created, so it seems that an error occurs while creating the views at the end of the script. However when a view is…
    Tags: database, tables, backup, mysql, table

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: