简体   繁体   English

mysqldump做部分备份-不完整的表转储

[英]mysqldump doing a partial backup - incomplete table dump

I have a database of about 6GB in size and it has a table with 12.6 million rows. 我有一个大约6GB的数据库,并且它有一个包含1260万行的表。 I tried to export the database into a SQL dump by: 我试图通过以下方式将数据库导出到SQL转储中:

mysqldump -u root -p db_name > db_name.sql mysqldump -u root -p db_name> db_name.sql

When the command finishes, the exported SQL dump file is just about 2GB and the primary table got exported only about 1 million rows. 该命令完成后,导出的SQL转储文件仅约2GB,而主表仅导出了约100万行。

What could possibly be wrong? 有什么可能是错的吗?

There is a 2GB filesize limit for some reason, the easiest way to get around this is using split : 由于某些原因,文件大小限制为2GB,解决此问题的最简单方法是使用split

mysqldump ... | split -b 250m - filename.sql-

You can also compress the files like this: 您也可以像这样压缩文件:

mysqldump ... | gzip -9c | split -b 250m - filename.sql.gz-

To restore from a non-compressed file, do this: 要从非压缩文件还原,请执行以下操作:

cat filename.sql-* | mysql ...

For a compressed file: 对于压缩文件:

cat filename.sql-* | zcat | mysql ...

Of course if you want a single file, you can then tar the result. 当然,如果只需要一个文件,则可以将结果tar

Obviously you can replace the 250m with a different size if you wish. 显然,您可以根据需要替换为其他尺寸的250m

I had similar, though all the tables were exported up to a certain point. 我有类似的东西,尽管所有表都导出到了某个点。

I'd removed a column on which an old redundant View depended, and mysqldump quietly choked trying to 'export' the View 我删除了旧的冗余View所依赖的列,并且mysqldump悄无声息地试图“导出”该View

您的文件系统可能仅限于2gb文件。

It's happen because some SQL Dump have limited size for dumping data. 发生这种情况是因为某些SQL转储的转储数据大小有限。 you could not dump the database if it over the limit. 如果数据库超出限制,则无法转储。

If you really want to do this you must compress the database.By using ZIP,GZIP,etc. 如果确实要执行此操作,则必须压缩数据库。使用ZIP,GZIP等。 Before dumping data. 转储数据之前。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM