4

I have 2 VPS and plan to migrate the DB from first to second. The original DB is taking around 15GB of storage and I manage to dump out a 7GB SQL. However, when I imported the SQL to second VPS, it takes up 2x of storage becoming 32GB.

My questions are:

  • What might cause my DB from 15GB to become 32GB by just dump+import?
  • How can I avoid this?

Below are some further detail:

  • Both VPS are not exactly same and so do the MySQL version. The source DB is version 5.5.47. The receiving DB is version 5.7.13.
  • The receiving DB is newly install and empty.
  • The command I used to dump out SQL is: mysqldump -u <username> -p --all-databases --add-drop-database --max_allowed_packet=16777216 --single-transaction > full_dump.sql. The reason I am setting max_allowed_packet is to have the same value compare to receiving DB
  • Not sure if this is relevant. If I do not specify single-transaction in my mysqldump command, it will error mysqldump: Got error: 2006: MySQL server has gone away when using LOCK TABLES
  • The source DB storage distribution is different from the receiving DB:

    14858M /var/lib/mysql

    14483M /var/lib/mysql/ibdata1

    365M /var/lib/mysql/wordpress

  • This is the receiving DB storage distribution:

    31558M /var/lib/mysql

    31306M /var/lib/mysql/wordpress

    337M /var/lib/mysql/wordpress/wp_wfLeechers.ibd

    101M /var/lib/mysql/wordpress/wp_1059_posts.ibd

  • I've tried to run table optimisation, but no impact
5
  • What Engine were the tables?? MyISAM? InnoDB?
    – Rick James
    Commented Sep 11, 2016 at 3:53
  • Majority of them are InnoDB, there are some MyISAM though, but not a lot compare to the total number of tables.
    – Kenaz Chan
    Commented Sep 12, 2016 at 2:16
  • How many tables? Are any of them PARTITIONed? Many columns CHAR as opposed to VARCHAR?
    – Rick James
    Commented Sep 12, 2016 at 2:53
  • Can you provide SHOW CREATE TABLE wp_wfLeechers; before and after? Also SHOW TABLE STATUS LIKE 'wp_wfLeechers';
    – Rick James
    Commented Sep 12, 2016 at 2:54
  • Hey thanks for prompt respond. However, I've accepted RonaldoMySQLDBA's answer. After I downgraded MySQL to v5.6, the DB import size is back to normal.
    – Kenaz Chan
    Commented Sep 13, 2016 at 4:20

2 Answers 2

2

The first thing that caught my eye was the versions of MySQL you are using.

You said

  • The source DB is version 5.5.47
  • The receiving DB is version 5.7.13

These two versions of MySQL use different default values for innodb_file_format

MySQL 5.7 has new ways of storing InnoDB as mentioned in the Documentation. Please note:

The Barracuda file format is required to use Compressed or Dynamic row formats and associated features such as compression, off-page storage for large variable-length columns, and large index key prefixes (see innodb_large_prefix). This restriction does not apply to tables stored in general tablespaces.

If your data has large variable-length columns, the result of reloading could be the storage of data and index info outside of your BTree Indexes and extra splitting of pages. See DYNAMIC and COMPRESSED Row Formats for more details on this. Many of the new InnoDB file format features are deprecated in MySQL 5.7 and will eventually disappear in future releases.

SUGGESTION #1

Even though deprecated, you could set innodb_file_format to Antelope on the MySQL 5.7 server, restart MySQL, and reload the mysqldump.

SUGGESTION #2

Use MySQL 5.5/5.6 as the Master instead of MySQL 5.7. Restart MySQL on the Master, and reload mysqldump into the Master.

SUGGESTION #3

Run ALTER TABLE innodbtable ROW_FORMAT=COMPRESSED; on all the MySQL 5.7 InnoDB tables.

GIVE IT A TRY !!!

0

Quite probably the old tables were MyISAM. (Do SHOW CREATE TABLE or peek inside the dump.) And the new tables were forced to be InnoDB.

In the long run this change is good.

A 2x size increase is to be expected in such a change.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.