Home >Database >Mysql Tutorial >Mysql备份与恢复方法_MySQL

Mysql备份与恢复方法_MySQL

WBOY
WBOYOriginal
2016-06-01 13:45:37813browse

bitsCN.com

 

mysqldump

备份整个数据库

mysqldump -u root -ppassword databasename >data.sql

//输入root密码即可

备份某个或多个表

mysqldump -u root -p databasename table1name table2name >data.sql

//输入root密码即可

只备份数据结构

mysqldump -u root -p databasename –no-data >data.sql

//输入root密码即可

恢复

mysql -u root -p –database=databasename

//输入root密码即可

 

备份:

/usr/local/mysql/bin/mysqldump –add-drop-table –all-databases –opt -f -uroot -pabc > /back/mysql-back.sql //整个数据库

tar czvf /back/mysql-back.tgz /back/mysql-back.sql

 

/usr/local/mysql/bin/mysqldump –add-drop-table –opt -f -uroot -p123 ywrc > /home/back/www/ywrc.sql //单个数据库

tar czvf /home/back/www/tar/ywrc-back.tgz /home/back/www/ywrc.sql

 

恢复:

mysql ywrc bitsCN.com

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn