Answer the question
In order to leave comments, you need to log in
Mysql throws an error on non-UTF8 characters, how to fix?
On local is:
mysql Ver 14.14 Distrib 8.0.0-dmr, for Linux (x86_64) using EditLine wrapper
PHP 5.6.29
Yii2 2.0.12
Error: SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xD1\x82\xD0\xBE \xD0...' for column 'content' at row 1
*************************** 1. row ***************************
Variable_name: character_set_client
Value: utf8mb4
*************************** 2. row ***************************
Variable_name: character_set_connection
Value: utf8mb4
*************************** 3. row ***************************
Variable_name: character_set_database
Value: utf8mb4
*************************** 4. row ***************************
Variable_name: character_set_filesystem
Value: binary
*************************** 5. row ***************************
Variable_name: character_set_results
Value: utf8mb4
*************************** 6. row ***************************
Variable_name: character_set_server
Value: utf8mb4
*************************** 7. row ***************************
Variable_name: character_set_system
Value: utf8
*************************** 8. row ***************************
Variable_name: collation_connection
Value: utf8mb4_unicode_ci
*************************** 9. row ***************************
Variable_name: collation_database
Value: utf8mb4_unicode_ci
*************************** 10. row ***************************
Variable_name: collation_server
Value: utf8mb4_unicode_ci
10 rows in set (0.00 sec)
Table: post
Create Table: CREATE TABLE `post` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created_at` int(11) NOT NULL,
`updated_at` int(11) NOT NULL,
`url` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`title` varchar(2048) COLLATE utf8mb4_unicode_ci NOT NULL,
`content` text COLLATE utf8mb4_unicode_ci NOT NULL,
`status` smallint(6) DEFAULT '10',
PRIMARY KEY (`id`),
UNIQUE KEY `post_url_unq` (`url`),
) ENGINE=InnoDB AUTO_INCREMENT=164 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
*************************** 1. row ***************************
Variable_name: character_set_client
Value: utf8mb4
*************************** 2. row ***************************
Variable_name: character_set_connection
Value: utf8mb4
*************************** 3. row ***************************
Variable_name: character_set_database
Value: utf8mb4
*************************** 4. row ***************************
Variable_name: character_set_filesystem
Value: binary
*************************** 5. row ***************************
Variable_name: character_set_results
Value: utf8mb4
*************************** 6. row ***************************
Variable_name: character_set_server
Value: utf8mb4
*************************** 7. row ***************************
Variable_name: character_set_system
Value: utf8
*************************** 8. row ***************************
Variable_name: character_sets_dir
Value: /usr/share/mysql/charsets/
Answer the question
In order to leave comments, you need to log in
https://stackoverflow.com/questions/10957238/incor...
https://stackoverflow.com/questions/1168036/how-to...
UPD: what SHOW CREATE TABLE and SHOW VARIABLES
LIKE '%char%' says ?
UPD2: How to fix error when writing to mysql "Incorrect string value"?
I also tried changing the table encoding to utf8mb4 and that didn't help either, but changing the encoding of the field itself helped:
ALTER TABLE `table` MODIFY `column` VARCHAR(255) CHARSET utf8mb4 null;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question