1

Error message:

Error 1366: Incorrect string value: '\xA7test for column `mycolumn` at row 1

db connection code:

db, err := sql.Open("mysql", "username:pass@tcp(127.0.0.1:3306)/mydb?charset=utf8mb4")

I tried running

SELECT
    `tables`.`TABLE_NAME`,
    `collations`.`character_set_name`
FROM
    `information_schema`.`TABLES` AS `tables`,
    `information_schema`.`COLLATION_CHARACTER_SET_APPLICABILITY` AS `collations`
WHERE
        `tables`.`table_schema` = DATABASE()
  AND `collations`.`collation_name` = `tables`.`table_collation`
;

and got this:

---------------------
| mytable | utf8mb4 |
---------------------

The string I'm trying to insert: §test

I looked at MariaDB incorrect string value error with utf8mb4 encoding and other things, but everything I saw says to set collation to utf8mb4 and to set charset to utf8mb4 which I have done.

1 Answer 1

0

The value should be \xC2\xA7test. \xA7 doesn't have a valid mapping in utf8(mb4).

select hex('§test')

C2A774657374

ref: fiddle

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.