Home  >  Article  >  Database  >  MySQL整个数据库的备份与还原

MySQL整个数据库的备份与还原

WBOY
WBOYOriginal
2016-06-07 15:19:511277browse

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 1.备份: [root]# /usr/bin/mysqldump -h127.0.0.1 -uusername -ppassword databasename /opt/share/1/backup.sql /usr/bin/mysqldump:用于执行的程序; -h:主机名称 -u:数据库用户 -p:数据库密码

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

  1.备份:

  [root]# /usr/bin/mysqldump -h127.0.0.1 -uusername -ppassword databasename >/opt/share/1/backup.sql

  /usr/bin/mysqldump:用于执行的程序;

  -h:主机名称

  -u:数据库用户

  -p:数据库密码

  databasename:数据库名称

  >/opt/share/1/backup.sql:导出文件的保存名称

  以这样的方式导出的文件打开后发现里面有乱码,这个是正常的,是因为导出时没有设置字体的缘故,这个不影响数据库内容的备份和还原。

  2.还原数据库:

  [root]# /usr/bin/mysql -h127.0.0.1 -uusername -ppassword databasename2 导入数据到databasename2中即可。

MySQL整个数据库的备份与还原

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