Thanks, This patch was useful. Finally getting somewhere with this.
It seems to have corrected it in my case, well, the errors have gone away. (So far, though I thought I’d fixed it twice before but the errors came back, so I’ll have to see if the problem is really fixed this time!)
Taking some advice from: How to support full Unicode in MySQL databases · Mathias Bynens
(Read that. It’s quite clear and explains the problem in more detail.)
Backup the database with mysqldump of course, in case something goes horribly wrong.
Show existing charset to see if this is the problem. If it’s utf8, you need to convert to utf8mb4.
(replace ‘rtdb’ if needed with your database name.)
use rtdb;
SELECT default_character_set_name FROM information_schema.SCHEMATA S WHERE schema_name = "rtdb";
Show structure of existing table:
MariaDB [rtdb]> describe AttachmentsIndex;
+---------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| Content | longtext | YES | MUL | NULL | |
+---------+------------------+------+-----+---------+----------------+
2 rows in set (0.003 sec)
Convert to utf8mb4:
ALTER DATABASE rtdb CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
ALTER TABLE AttachmentsIndex CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE AttachmentsIndex CHANGE Content Content longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
OPTIMIZE TABLE AttachmentsIndex;
(Also there is a REPAIR option suggested, but in my case, it isn’t supported for the database type.)
The link above also has suggestions to change your mysql client/server config if needed, i.e., how to set it to utf8mb4 if it’s utf8. I didn’t need to change this, only apply the patch above to RT.
mysql> SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';
+--------------------------+--------------------+
| Variable_name | Value |
+--------------------------+--------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| collation_connection | utf8mb4_unicode_ci |
| collation_database | utf8mb4_unicode_ci |
| collation_server | utf8mb4_unicode_ci |
+--------------------------+--------------------+
10 rows in set (0.00 sec)