1. use commands to back up the home page to enter the mysql bin directory 1. backup data mysqldump-uusername-ppassworddiscuz & gt; in this way, the discuz_2010-04-01sql backs up all the table structures and data in the discuz database to the discuz_2010-04-01sql.
On the home page, go to the mysql bin directory.
1. back up data
# Mysqldump-uusername-ppassword discuz> discuz_2010-04-01. SQL
In this way, all the table structures and data of the discuz database are backed up to the discuz_2010-04-01. SQL,
If the data volume occupies a large space, you can use gzip to compress the data,
The command is as follows:
# Mysqldump-uusername-ppassword discuz | gzip> discuz_2010-04-01. SQL .gz
When the system crashes and the system is rebuilt, data can be restored as follows:
# Mysql-uusername-ppassword discuz <discuz_2010-04-01. SQL
Direct Recovery from compressed files:
# Gzip <discuz_2010-04-01. SQL .gz | mysql-uusername-ppassword discuz
II. using crontab, the system regularly backs up mysql databases every day
1. create the path to save the backup file/mysqldata
# Mkdir/mysqldata
2. create the/usr/sbin/bakmysql file.
Enter the following content:
Mysqldump-umysql-p51uptry uptry | gzip>/mysqldata/uptry 'date between them y-m-1_d_1_h1_m1_s'. SQL .gz
3. Modify file attributes so that they can be executed
# Chmod + x/usr/sbin/bakmysql
4. modify/etc/crontab
Add
01 3 *** root/usr/sbin/bakmysql
Indicates the use instructions for backing up crontab at three o'clock every day
On the home page, go to the mysql bin directory.
Create a database
# Mysqladmin create discuz
Restore data
# Mysql discuz </mysqldata/discuz_2010-04-01. SQL
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service