dump mysql database_【MySQL Database】数据迁移工具:mysqldump
[mysql@wallet01 ~]$ mysqldump --help
-u, --user=name 指定连接数据库服务器使用的用户
-p, --password 指定连接数据库服务器使用的密码
-P, --port=# 指定连接数据库服务器使用的端口
-h, --host=name 指定连接数据库服务器的主机名
-A, --all-databases 备份全部的数据库
-B, --databases 备份指定的数据库
-t, --no-create-info 仅备份表记录
-d, --no-data 仅备份表结构
-w, --where=name 仅备份表中匹配条件的记录
-E, --events 备份数据库的事件
-R, --routines 备份数据库的存储过程与函数
--triggers 备份表的触发器
-x, --lock-all-tables 锁定全部数据库中的全部表。
-T, --tab=nameCreate tab-separated textfile for each table to given path. (Create .sql and .txt files.)
--fields-terminated-by=nameFields in the output file are terminated by the given string.
--fields-enclosed-by=nameFields in the output file are enclosed by the given character.
--lines-terminated-by=nameLines in the output file are terminated by the given string.
--dump-slave[=#] This causes the binary log position and filename of the
master to be appended to the dumped data output. Setting
the value to 1, will printit as a CHANGE MASTER command
in the dumped data output; if equal to 2, that command
will be prefixed with a comment symbol. This option will
turn --lock-all-tables on, unless --single-transaction is
specified too (in which case a global read lock is only
taken a short time at the beginning of the dump - don't
forget to read about --single-transaction below). In all
cases any action on logs will happen at the exact moment
of the dump.Option automatically turns --lock-tables off.
--master-data[=#] This causes the binary log position and filename to be
appended to the output. If equal to 1, will print it as a
CHANGE MASTER command; if equal to 2, that command will
be prefixed with a comment symbol. This option will turn
--lock-all-tables on, unless --single-transaction is
specified too (in which case a global read lock is only
taken a short time at the beginning of the dump; don't
forget to read about --single-transaction below). In all
cases, any action on logs will happen at the exact moment
of the dump. Option automatically turns --lock-tables
off.
--single-transaction
Creates a consistent snapshot by dumping all tables in a
single transaction. Works ONLY for tables stored in
storage engines which support multiversioning (currently
only InnoDB does); the dump is NOT guaranteed to be
consistent for other storage engines. While a
--single-transaction dump is in process, to ensure a
valid dump file (correct table contents and binary log
position), no other connection should use the following
statements: ALTER TABLE, DROP TABLE, RENAME TABLE,
TRUNCATE TABLE, as consistent snapshot is not isolated
from them. Option automatically turns off --lock-tables.
备份指定的库
[mysql@wallet01 ~]$ mysqldump -uroot -p --databases soe > soe.sql
备份指定的表
[mysql@wallet01 ~]$ mysqldump -uroot -p soe customer >customer.sql
仅备份表结构
[mysql@wallet01 ~]$ mysqldump -uroot -p --no-data soe customer >customer.sql
仅备份表记录
[mysql@wallet01 ~]$ mysqldump -uroot -p --no-create-info soe customer >customer.sql
仅备份表中匹配条件的记录
[mysql@wallet01 ~]$ mysqldump -uroot -p --where="c_state='z3'" soe customer >customer.sql
还原指定的库
[mysql@wallet01 ~]$ mysql -uroot -p soe < soe.sql
还原指定的表
[mysql@wallet01 ~]$ mysql -uroot -p soe < customer.sql
表结构备份为sql文件,表记录备份为文本文件
[mysql@wallet01 ~]$ mysqldump -uroot -p --tab=/var/lib/mysql-files \
--fields-terminated-by=',' --fields-enclosed-by='"' --lines-terminated-by='\n' soe customer
[mysql@wallet01 ~]$ cd /var/lib/mysql-files
[mysql@wallet01 mysql-files]$ ls -lh
total 165M
-rw-rw-r-- 1 mysql mysql 2.5K Sep 18 10:08 customer.sql
-rw-rw-rw- 1 mysql mysql 165M Sep 18 10:08 customer.txt
还原表结构
[mysql@wallet01 ~]$ mysql -uroot -p soe < customer.sql
还原表记录
[mysql@wallet01 ~]$ mysqlimport -uroot -p soe \
--fields-terminated-by=',' \
--fields-enclosed-by='"' \
--lines-terminated-by='\n' /var/lib/mysql-files/customer.txt
Enter password:
soe.customer: Records: 300000 Deleted: 0 Skipped: 0 Warnings: 0
dump mysql database_【MySQL Database】数据迁移工具:mysqldump相关推荐
- MySQL 到PostgreSQL 的数据迁移工具
2019独角兽企业重金招聘Python工程师标准>>> pg_chameleon is available on pypi for download python 包下载地址 The ...
- php导出数据库的指定表数据,MYSQL教程mysql数据库导出指定表数据的方法
<MYSQL教程mysql数据库导出指定表数据的方法>要点: 本文介绍了MYSQL教程mysql数据库导出指定表数据的方法,希望对您有用.如果有疑问,可以联系我们. 导读:linux下导出 ...
- mysql备份数据出现mysqldump: Got error: 1049: Unknown database ‘jxgl>jxgl.sql‘ when selecting the database
文章目录 使用mysqldump备份数据出现mysqldump: Got error: 1049: Unknown database 'jxgl>jxgl.sql' when selecting ...
- MySQL数据迁移工具
MySQL Migration Toolkit MySQL Migration Toolkit 是MySQL提供的开源GUI软件工具.可以针对Microsoft Access.Microsoft S ...
- 3.2.3 Sqoop 数据迁移工具, 导入数据import, MySQL到HDFS/Hive, 导出数据export,增量数据导入, Sqoop job,常用命令及参数
目录 数据迁移工具 -- Sqoop 第一部分 Sqoop概述 第二部分 安装配置 第三部分 应用案例 第 1 节 导入数据import MySQL 到 HDFS MySQL 到 Hive 第 2 节 ...
- DM 数据迁移工具——DTS(MySQL数据迁移到DM8数据库 Windows环境)
DM 数据迁移工具--DTS MySQL数据迁移到DM8数据库 Windows环境 DM 数据迁移工具 DM DTS 提供了主流大型数据库迁移到 DM.DM 到 DM.文件迁移到 DM 以及 DM 迁 ...
- mysql导出结构及数据结构,Mysql导出数据结构 or 数据
如果我们单单只想导出mysql数据表结构,通过navcat工具还不行,这时我们可以用mysqldump工具 在mysql server的安装目录:C:\Program Files\MySQL\MySQ ...
- 【mysql】mysql数据备份与恢复
数据的重要性不言而喻,所以做好数据的备份工作显得尤其必要,不知不觉我又开始扯犊子了.... 一.逻辑备份与恢复 数据库逻辑备份就是备份软件按照最初设计的逻辑关系,以数据库的逻辑结构对象为单位,将数据库 ...
- mysql 查看备份工具_MariaDB/MySQL备份和恢复(一):mysqldump工具用法详述【转】
本人博客搬家(本站无精力更新和维护):骏马金龙www.junmajinlong.com 1.备份分类 按照是否能够继续提供服务,将数据库备份类型划分为: 热备份:在线备份,能读能写 温备份:能读不能写 ...
最新文章
- 不要再用arxiv链接了!为了让论文引用更规范,上交毕业生、南加州大学华人博士创建了一个小工具...
- 检查Bash Shell脚本中输入参数的存在
- Linux课程---7、shell技巧(获取帮助命令)
- 依赖注入之Autofac使用总结
- spring boot在运行测试类Error creating bean with name ‘serverEndpointExporter‘ defined...问题解决方案
- BitNami Redmine Stack
- JS键盘事件(非常详细)
- C#Redis哈希Hashes
- 彻夜怒肝!Spring Boot+Sentinel+Nacos高并发已撸完,快要裂开了!
- 数据库的四个范式之间的区别
- JSON Server在快速开发过程中的使用
- 多线程篇三:线程同步
- 第38周星期四电话会议忙碌的一天
- 数据结构期末复习第一章绪论
- Virtualbox中Ubuntu与windows共享文件夹设置
- 浅谈RS-485协议
- 保险经纪公司达信联合IBM开发区块链平台
- Monte-Carlo Dropout(蒙特卡罗 dropout),Aleatoric Uncertainty,Epistemic Uncertainty
- IllegalStateException: Content has been consumed
- Centos7 Python3.6+Qt5.12.9+ PyQt5.12+Sip v5+QScintilla-2.10+Eric6