MySQL Forums
Forum List  »  Newbie

Re: Update sql terminated with an incorrect string value error in MySQL 8.0.21
Posted by: zhu guan
Date: October 13, 2022 10:04PM

I found the cause of the problem.
Incorrect string value error above is because the character '𣘺' requires 4-bytes to be represented in UTF-8 encoding.
To solve the error, you need to use the utf8mb4 character set.

The solution is as follows:

Here’s the query to alter your database, table, or column to utf8mb4 character set:

-- Change a database
ALTER DATABASE [database_name]
CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;

-- Change a table
ALTER TABLE [table_name]
CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- Change a column
ALTER TABLE [table_name]
CHANGE [column_name] [column_name] VARCHAR(255)
CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

When I changed the character set of the sei column to utf8mb4, the update statement works.
The new database was exported from the old database with the mysqldump command,
and the exported table creation statement contains the character set as follows:

CREATE TABLE `chartest` (
`id` int NOT NULL,
`sei` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Does the mysqldump command support exporting results without the "DEFAULT CHARSET=utf8" statement?

Options: ReplyQuote


Subject
Written By
Posted
Re: Update sql terminated with an incorrect string value error in MySQL 8.0.21
October 13, 2022 10:04PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.