HubsInfo Network
Discord Social hublist.config PHP Linux Web Hosting Online Games Free Web Directory

Backup and restore large mysql databases...

0 Members and 1 Guest are viewing this topic.

Backup and restore large mysql databases...
« on: June 18, 2014, 10:05:18 AM »
To Backup Mysql Database

Code: [Select]
$ mysqldump  -u [uname] -p[pass] [dbname] > [backupfile.sql]
  • [uname] Your database user name
  • [pass] The password for your database (note there is no space between -p and the password)
  • [dbname] The name of your database
  • The file name for your database backup



To Backup Mysql Database with compress

If your mysql database is very big, you might want to compress the output of mysql dump. Just use the mysql backup command below and pipe the output to gzip, then you will get the output as gzip file.

Code: [Select]
$ mysqldump -u [uname] -p[pass] [dbname] | gzip -9 > [backupfile.sql.gz]

If you want to uncompress you database file created in above step the use this command

Code: [Select]
$ gunzip [backupfile.sql.gz]




To Restore Mysql Database

To restore the database you need to create the database in target machine then use this command

Code: [Select]
$ mysql -u [uname] -p[pass] [db_to_restore] < [backupfile.sql]




To Restore Compressed Mysql Database

Code: [Select]
gunzip < [backupfile.sql.gz] | mysql -u [uname] -p[pass] [dbname]



--
« Last Edit: March 17, 2020, 10:18:06 AM by hubsinfo »

 


Linux Ubuntu Guides Linux games - Lutris.net