简体   繁体   English

MySQL 数据库-转储导入

[英]MySQL database-dump import

I need some details on importing and exporting a MySQL 8 database.我需要一些有关导入和导出 MySQL 8 数据库的详细信息。

  1. If the entire database is backed up in one dump, is it possible to restore a single table, or should the individual tables be exported?如果整个数据库都备份在一个转储中,是否可以恢复单个表,还是应该导出单个表?

  2. When setting FOREIGN_KEY_CHECKS , UNIQUE_CHECKS , and AUTOCOMMIT to 0 , is this done to the database that you are importing to from MySQL?FOREIGN_KEY_CHECKSUNIQUE_CHECKSAUTOCOMMIT设置为0时,是否对要从 MySQL 导入的数据库执行此操作? If so, it seems to have no effect for me.如果是这样,它似乎对我没有影响。 If not, please provide the details on how to do these settings.如果没有,请提供有关如何进行这些设置的详细信息。

  3. Should the settings in 2.) be done to the database prior to exporting in order to get faster importing?是否应该在导出之前对数据库进行 2.) 中的设置以加快导入速度?

This 12 hour import of one table with 5M records and several indexes is for the birds.一张包含 5M 记录和多个索引的表的 12 小时导入是针对鸟类的。

  1. Since the dump is one large text file consisting of almost only SQL commands you can also delete portions of it, especially the CREATE TABLE and INSERT INTO ones that you wish to skip.由于转储是一个大文本文件,几乎只包含 SQL 命令,您还可以删除其中的部分内容,尤其是您希望跳过的CREATE TABLEINSERT INTO部分。 Exporting only portions of a database has the same effect.仅导出数据库的一部分具有相同的效果。 Sometimes you don't have the choice (either no text editor available dealing with large files, or no source database to export available).有时您别无选择(要么没有可用于处理大文件的文本编辑器,要么没有可导出的源数据库)。
  2. Those are to increase performance when writing (importing), whereas on reading (exporting) they have no effect and would not make sense (you don't check constaints when reading).这些是为了在写入(导入)时提高性能,而在读取(导出)时它们没有效果并且没有意义(您在读取时不检查约束)。 They are in the dump, because you always plan to import it again - it's not a log of the export, but merely wants to be user friendly so you don't have to do it.它们在转储中,因为您总是计划再次导入它 - 它不是导出日志,而只是想对用户友好,因此您不必这样做。 The manual:手册:
  1. No. Export and import are unbound to each other - you don't want to disable any constraints or checks when just reading (exporting) data and you also would not have any benefit from doing so.不可以。导出和导入彼此不受约束——您不想在读取(导出)数据时禁用任何约束或检查,这样做也不会有任何好处。

What you haven't stated is how you import and with which program: via console and the "mysql" client (ie mysql < data.sql )?您没有说明的是您如何导入以及使用哪个程序:通过控制台和“mysql”客户端(即mysql < data.sql )? Have you checked the operating system's performance during the import to see a bottleneck (ie high disk usage, much swapping, no more RAM left, CPU usage...)?您是否在导入过程中检查过操作系统的性能以发现瓶颈(即磁盘使用率高、交换量大、内存不足、CPU 使用率...)?

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

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