mysqldump
dumps different representations of data when called with/without --no-create-info
.
Test case
First, create the test
table and populate it with interesting data.
CREATE TABLE `test` (
`value` longtext
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- insert 'crème'
insert into test values(UNHEX('6372C3A86D65'));
Then, dump the data using with and without --no-create-info
:
mysqldump test_db test > dump_test.sql
mysqldump --no-create-info test_db test > dump_test2.sql
These files encode crème differently:
dump_test.sql
encodes it as0x6372C3A86D65
(è
is0xC3A8
)dump_test2.sql
encodes it as0x63725CE86D65
(è
is0x5CE8
)
Restoring the dump from dump_test.sql
works correctly, a complete row is restored:
mysql test_db < dump_test.sql
Restoring the dump from dump_test2.sql
produces an incorrect result where data is truncated to just cr
(0x6372
). Note that structure of the table is the same:
mysql test_db < dump_test2.sql
No error nor warning is given. These two files differ - besides encoding of crème
- only by:
-- Table structure for table `test`
--
DROP TABLE IF EXISTS `test`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `test` (
`value` longtext
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
Question
Why does this happen? Is it documented anywhere? Can I/how can I correctly restore the dump created with --no-create-info
data?
Additional info
# mysqldump used to dump the database
$ mysqldump -V
mysqldump Ver 8.0.22-0ubuntu0.20.04.3 for Linux on x86_64 ((Ubuntu))
# Server
version_component: Percona Server (GPL), Release '35', Revision '5688520'
version: 5.7.32-35
5CE8
is\è
when using character set latin1.