游客发表
一、入导mysqldump工具介绍
mysqldump 是出命个mysql数据库自带的命令行工具,单线程执行,入导可以用来备份和还原数据。出命可以生成 CSV、免费源码下载入导TXT、出命XML格式的入导文件输出。

查看帮助文档

二、出命利用mysqldump进行数据库备份
1. 数据库操作
(1) 备份所有数据库
mysqldump -h 主机IP -uroot -p --all-database > /data/dball.sql(2) 备份多个数据库
mysqldump -h 主机IP -uroot -p db1 db2 db3 >/data/db123.sql(3) 备份单数据库
mysqldump -h 主机IP -uroot -p db >/data/db.sql2. 数据库中表操作
(1) 备份数据库中多张表
mysqldump -h 主机IP -uroot -p db table1 table2 >/data/db_table12.sql(2) 备份数据库中一张表
mysqldump -h 主机IP -uroot -p db table >/data/db_table.sql(3) 根据where进行备份
mysqldump -h 主机IP -uroot -p db table --where " 查询条件" >/data/db_table.sql(4) 备份数据中,入导忽略某张表
mysqldump -h 主机IP -uroot -p db --ignore-table=logtable --ignore-table=historytable >/data/db_table.sql3. 数据库只导出表结构或数据,香港云服务器出命正常情况下导出表结构和数据都存在
(1) 只导出表结构,入导不导出数据
mysqldump -h主机IP -d -uroot -p 数据库名 > db.sql
(2) 只导出数据,出命不导出表结构
mysqldump -h主机IP -t -uroot -p 数据库名 > db.sql
4. 通用备份命令
mysqldump -h -uroot -p --default-character-set=utf-8 --set-gtid-purged=OFF --lock-tables=false -R -E --databases db | gzip > /root/db.sql.gz --default-character-set=utf-8 指定字符集 --set-gtid-purged=OFF 重新生产GTID,入导而不用原来的出命 --lock-tables 不锁表 -R Dump stored routines (functions and procedures) -E Dump events gzip 对备份进行压缩三、利用mysqldump进行数据库还原
第一种:
mysqldump -h 主机IP -uroot -p db < /root/db.sql第二种:source 命令
[root@izbp10lvzs7171weegqj8xz ~]# mysql -uroot -p mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 62669 Server version: 5.7.23-log MySQL Community Server (GPL) Copyright (c) 2000,入导 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type help; or \h for help. Type \c to clear the current input statement. 21: root@localhost:[(none)]> use test; Database changed 21: root@localhost:[test]> source /root/db.sql亿华云随机阅读
热门排行
友情链接