How to backup & restore database to MySQL server on Ubuntu

Backup Only Table from MySQL Database Using mysqldump
# mysqldump  -u[uname] -p[pass] [dbname] > [backupfile.sql];
Example
 mysqldump -uroot -pabcd  shopmanagementdb > shopmanagementdbback.sql ;

Backup Only Table structure from  MySQL Database Using mysqldump
# mysqldump -n  -d  -u[uname] -p[pass] [dbname] > [backupfile.sql];
Example
 mysqldump -n  -d  -uroot -pabcd  shopmanagementdb > shopmanagementdbback.sql ;

Backup Only Store procedure and function  from MySQL Database Using mysqldump
# mysqldump -n -t -d --routines  -u[uname] -p[pass] [dbname] > [backupfile.sql];
Example
 mysqldump -n -t -d --routines  -uroot -pabcd  shopmanagementdb > shopmanagementdbback.sql;

Backup Table and Store Produce from  MySQL Database Using mysqldump
#  mysqldump --routines -u [uname] -p[pass] [dbname] > [backupfile.sql];
Example
mysqldump  --routines -uroot -pabcd  shopmanagementdb > shopmanagementdbback.sql ;

Backup Table and Store Produce and function  from MySQL Database Using mysqldump for any language
#  mysqldump --routines -u [uname] -p[pass] --default-character-set=utf8  [dbname] > [backupfile.sql];
Example
mysqldump  --routines -uroot -pabcd --default-character-set=utf8 shopmanagementdb > shopmanagementdbback.sql;


Backup only Table data  from  MySQL Database Using mysqldump
#  mysqldump  -u [uname] -p[pass] -t [dbname] > [backupfile.sql];
Example
mysqldump  -uroot -pabcd  -t shopmanagementdb > shopmanagementdbback.sql ;


Backup specific Table data  from  MySQL Database Using mysqldump
#  mysqldump  -u [uname] -p[pass] -t [dbname] table1 table2 > [backupfile.sql];
Example
mysqldump  -uroot -pabcd  -t shopmanagementdb customer branch > shopmanagementdbback.sql ;

Restore MySQL Database
# mysql -u[uname] -p[pass] [dbname] < [backupfile.sql] ;
Example
mysql -uroot -pabcd  shopmanagementdb < shopmanagementdbback.sql;

No comments:

Post a Comment