Home > Database > Mysql Tutorial > body text

mysql 数据库 备份还原命令_MySQL

WBOY
Release: 2016-06-01 13:51:35
Original
1220 people have browsed it

Linux as 5.5  MySQL 5.0 数据库备份与恢复:

1,  用 mysqldump 命令进行备份:
    在命令提示符窗口(注意不是 MySQL 的 MySQL Command Line Client 窗口)中输入, 
    mysqldump -hlocalhost -uroot -proot        temp  > temp_2011.sql 
    mysqldump -hlocalhost -u root -proot    temp > temp_2011.sql 
    mysqldump -h localhost -u root -proot  temp > temp_2011.sql
    先进入到 MySQL想要存放备份文件的目录下(便于存放生成的*.sql文件).

也可以在命令里指定想要存放的目录:比如存放到根目录下,命令如下:

mysqldump -h localhost -u root -proot  temp > temp_2011.sql > /2011.sql

    其中-h,-u两个参数名与参数值之间可用或不用空格分隔,

    但-p参数的参数名与参数值之间是一定不能加空格的,也可以这样输入: 
    mysqldump -hlocalhost -uroot -p temp > temp_2011.sql
    Enter password: root
    在后面再输入密码也可以成功.
    -h指出备份的数据库在本机,-u指出用户名,-p指出密码,temp为数据库名,后面可具体指定备份的数据表.
    结果生成的 temp_2011.sql 文件会自动存在指定目录下.
   

2,  用mysql 命令进行恢复: 
   mysql  -hlocalhost  -uroot  -proot          temp      输入此命令后,数据库中的数据将恢复到备份时的数据.
    注意:恢复时, temp 必须存在,数据库可空.恢复时会自动删除要恢复的表,再重新创建,插入数据.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!