MYSQL DATABASE BACKUP
Jump to navigation
Jump to search
Mysql Backup and Restore
List Databases
Login to server
mysql
List databases
show databases;
List Tables in a database
use databasename show tables;
Bakcup a single database
done from bash - no need to log in to mysql mysqldump -u root -ppassword sugarcrm > sugarcrm.sq syntax mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
Backup a single table
mysqldump -u root -ppassword databasename table > sugarcrm.sq
Backup Multiple Database
- log into mysql
mysql -u root -pyourpassword mysql> show databases;
this will give you a list of databases
For example, if you want to take backup of both sugarcrm and bugs database, execute the mysqldump as shown below:
mysqldump -u root -ptmppassword --databases bugs sugarcrm > bugs_sugarcrm.sql
- Verify the bugs_sugarcrm.sql dumpfile contains both the database backup.
# grep -i "Current database:" /tmp/bugs_sugarcrm.sql
-- Current Database: `mysql`
-- Current Database: `sugarcrm`
Backup all the databases:
The following example takes a backup of all the database of the MySQL instance. # mysqldump -u root -ptmppassword --all-databases > /tmp/all-database.sql
Backup a specific table:
In this example, we backup only the accounts_contacts table from sugarcrm database. mysqldump -u root -ptmppassword sugarcrm accounts_contacts > /tmp/sugarcrm_accounts_contacts.sql