简体   繁体   中英

MySQL database-dump import

I need some details on importing and exporting a MySQL 8 database.

  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? 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?

This 12 hour import of one table with 5M records and several indexes is for the birds.

  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. 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 )? 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...)?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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