MySQLdump只导出表结构或只导出数据的实现方法
mysqldump #只导出表结构,不导出数据 mysqldump --opt -d 数据库名 -u root -p > xxx.sql
备份数据库
mysqldump 数据库名 >数据库备份名 mysqldump -A -u用户名 -p密码 数据库名>数据库备份名 mysqldump -d -A --add-drop-table -uroot -p >xxx.sql
1.导出结构不导出数据
mysqldump --opt -d 数据库名 -u root -p > xxx.sql
2.导出数据不导出结构
mysqldump -t 数据库名 -uroot -p > xxx.sql
3.导出数据和表结构
mysqldump 数据库名 -uroot -p > xxx.sql
4.导出特定表的结构
mysqldump -uroot -p -B 数据库名 --table 表名 > xxx.sql
导入数据:
由于mysqldump导出的是完整的SQL语句,所以用mysql客户程序很容易就能把数据导入了:
$ mysql 数据库名 < 文件名 或 mysql> source /tmp/xxx.sql
《 “MySQLdump数据的导入导出” 》 有 3 条评论
MySQL数据库的复制:
`
shell> mysqldump db1 > dump.sql
shell> mysqladmin create db2
shell> mysql db2 < dump.sql
或
shell> mysqldump mydbname | mysql new_db_name
或
shell> mysqldump mydbname | ssh host2 “mysql new_db_name”
`
https://dev.mysql.com/doc/refman/5.6/en/mysqldump-copying-database.html
http://stackoverflow.com/questions/675289/cloning-a-mysql-database-on-the-same-mysql-instance
http://stackoverflow.com/questions/1887964/duplicate-entire-mysql-database
mydumper 完全参考手册
https://dbarobin.com/2015/04/07/mydumper/
http://centminmod.com/mydumper.html
不同场景下 MySQL 的迁移方案
https://dbarobin.com/2015/09/15/migration-of-mysql-on-different-scenes/
4.5.4 mysqldump — A Database Backup Program
https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html
`
mysqldump requires at least the SELECT privilege for dumped tables
, SHOW VIEW for dumped views
, TRIGGER for dumped triggers
, LOCK TABLES if the –single-transaction option is not used
, and (as of MySQL 8.0.21) PROCESS if the –no-tablespaces option is not used.
Certain options might require other privileges as noted in the option descriptions.
`
mysqldump命令想要正常执行,它至少需要哪些权限?
Which are the minimum privileges required to get a backup of a MySQL database schema?
https://dba.stackexchange.com/questions/55546/which-are-the-minimum-privileges-required-to-get-a-backup-of-a-mysql-database-sc
`
mysqldump –no-data –routines –triggers …
`