0

Mysql version: 10.2.25-MariaDB

ENGINE=InnoDB

I'm trying to save data like: پہمغیابج ماوبرنم کرنامت

But it just shows question marks: ????

I have already tried:

Utf8, Utf8mb4 charset & utf8_general_ci, utf8_unicode_ci collation

but none of them seems to be working.

What charset or collation should I use to save data in multiple languages?

Update:

The same project is saving & retrieving data in multiple languages on my local machine (using mysql on local machine). But the server where I have deployed my code is using maria-db.

Update 2:

To make sure that its database issue and the client is sending correct data to db, I saved data to a text file just before saving it to database. The text file contains correct data but database has ??? in it.

Irfan Y
  • 1,242
  • 2
  • 21
  • 68
  • 1
    *But it just shows question marks* In UTF8 CLI console window? – Akina Jan 30 '20 at 19:26
  • Maybe your client is not able to display them back and the data is good in the database. – The Impaler Jan 30 '20 at 19:30
  • I'm using phpmyadmin, I just checked data in table and it has `???` – Irfan Y Jan 30 '20 at 19:31
  • I have updated the question, please check – Irfan Y Jan 30 '20 at 19:38
  • You need ufto 8 all the way through, the database, table and the client connection has also to specify uto in his string. Depend which languag you are using like DOT NET you have also to convert unicode in utf8 . so check which side hasn't git utf8 – nbk Jan 30 '20 at 19:54
  • 2
    Does this help? https://stackoverflow.com/questions/279170/utf-8-all-the-way-through – Dave Jan 30 '20 at 20:30
  • Some of Chinese, plus Emoji, need utf8mb4, not just utf8. – Rick James Feb 05 '20 at 22:26
  • See "question mark" in https://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored – Rick James Feb 05 '20 at 22:26

2 Answers2

1
SHOW VARIABLES LIKE 'character_set%'

Check character_set_database, character_set_connection and character_set_result.

Most probably the server default character set is not UTF-8 so you need to configure your connection manually by issuing SET NAMES UTF8 just after connection.

In php you can do the same using $connection->set_charset('UTF8')

Also you will need to check your tables character set (SHOW CREATE TABLE xyz). If your database character set was NOT set UTF8 and you created tables without character set specified per table/columns, the tables cannot hold the UTF8 characters and you will need to re-create them.

fifonik
  • 1,556
  • 1
  • 10
  • 18
0

I added charset=utf8 in connectionstring and it worked.

Irfan Y
  • 1,242
  • 2
  • 21
  • 68