How to save a Chinese character 𥚃 in MySQL - mysql

I am unable to save the character 𥚃 on mySQL 5.5. I have tried collation utf8mb4 and utf32. I have to store both Chinese and English characters in the same table.

I was able to save this charecter by using utf8mb4 charecterset on mysql server. So the output of show variables like 'char%'; should be all utf8mb4 except for perhaps system charset.

Try utf8 general, and also, don't change to execute
SET NAMES utf8;
beore the actual query, which is quite an important part

Related

MySQL error 3988 Conversion from collation utf8mb4_general_ci into latin1_swedish_ci impossible for parameter

I am getting this error when doing a big insert query into a table on MySQL 8:
Error 3988: Conversion from collation utf8mb4_general_ci into latin1_swedish_ci impossible for parameter
The data originally comes from a table with the utf8mb4 character set and then after processing it is inserted into a table with the latin1 character set.
It's getting stuck on this two-byte character: ż.
Is there an easy way for me to get MySQL to replace or strip out these characters, or a way for me to sanitise the input without sacrificing characters like ä which it seems to be able to handle?
If you use PHP framework like Laravel try to find file called database.php in config directory anf change mysql configs to latin1_swedish_ci

#1115 - Unknown character set: 'utf8mb4'

I have a local webserver running on my pc to which I use for local development. I'm now at the stage of exporting the database and importing onto my hosted VPS.
When exporting then importing I get the following error!
1115 - Unknown character set: 'utf8mb4'
Can somebody point me in the right direction?
The error clearly states that you don't have utf8mb4 supported on your stage db server.
Cause: probably locally you have MySQL version 5.5.3 or greater, and on stage/hosted VPS you have MySQL server version less then 5.5.3
The utf8mb4 character sets was added in MySQL 5.5.3.
utf8mb4 was added because of a bug in MySQL's utf8 character set.
MySQL's handling of the utf8 character set only allows a maximum of 3
bytes for a single codepoint, which isn't enough to represent the
entirety of Unicode (Maximum codepoint = 0x10FFFF). Because they
didn't want to potentially break any stuff that relied on this buggy
behaviour, utf8mb4 was added. Documentation here.
Solution 1:
Simply upgrade your MySQL server to 5.5.3 (at-least) - for next time be conscious about the version you use locally, for stage, and for prod, all must have to be same.
A suggestion - in present the default character set should be utf8mb4.
Solution 2 (not recommended): Convert the current character set to utf8, and then export the data - it'll load ok.
Sometimes I get similar problems while using HeidiSQL which by default exports in utf8mb4 character encoding. Not all MySQL installations support this encoding and importing such data leads to similar error messages. My workaround then is to export data using phpMyAdmin, which exports in utf8. There are problably other tools and possible ways like manually editing dump file, converting it from utf8mb4 to utf8 (if needed) and changing SET NAMES utf8mb4 to SET NAMES utf8. Utf8mb4 is a superset of utf8, so if you're absolutely sure, that your data is just utf8, then you can simply change SET NAMES in dump file to utf8.
Open sql file by text editor find and replace all
utf8mb4 to utf8
Import again.
This helped me
ALTER TABLE your_table_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

Store text in database in some languages

Can anyone tell me how can i store for example russian words in database? Please write an example. I know that i must use unicode, but don't know how use with mySql.
Thanks all for response.
You should create a database with utf8 character set and russian collation.
Find the russian collation:
SHOW COLLATION LIKE '%russian%'
Then create the database:
CREATE DATABASE db_name CHARACTER SET utf8 COLLATE latin1_russian_ci;
You can also ALTER it if you already have one.
Read the manual here https://dev.mysql.com/doc/refman/5.7/en/charset-database.html

incorrect output 4 bytes symbols in mysql table with utf8mb4 encode

I want to insert via phpmyadmin 4 bytes character in the tabel. (phpmyadmin version is 5.5.33).
I assigned Server connection collation to utf8mb4_general_ci collation;
Database has utf8mb4 encode;
Table and column has utf8mb4 encode;
I tryed to insert 𩸽 symbol and it was success and without any errors! But this symbol in the table is displayed as ????.
Can someone help, please?
So I would reccomend you to check what is the application web encoding because your problem is not the data itself is the program that is printing it. If your php administration tool or the web container (apache most probably) that is hosting this application doesn't have your character encoding you wont see your character. Most of theese application use just UTF8 as encoding therefore I suggest you to change your database to this encoding just UTF8 and the collation to utf8_general_ci.
Your question is most probably related with this one How to display UTF-8 characters in phpMyAdmin?

How to store non-english characters?

Non-english characters are messed up in a text column. Arabic text looks like this:
نـجـم سـهـيـل
How to store non-english characters correctly?
You should consider using utf8 to store your text.
You can do this at the database creation:
CREATE DATABASE mydb
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE utf8_general_ci;
You can also configure mysql at installation or at startup to use utf8 (see Mysql manual)
The mysql manual pages cover all aspects of characterset and collations: http://dev.mysql.com/doc/refman/5.0/en/charset.html
The character set of the connection can be changed by
SET CHARACTER SET utf8
More details here and in the chapter Character set support
What OS are you using?
If Linux then it's good to have a system locale set to utf8 also, like "en_US.utf8".
And, to be sure, issue an "SET NAMES UTF8" command to mysql just after connection.
(db character set/collation must also be utf8)
The query below solved the issue.
ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;