Answer the question
In order to leave comments, you need to log in
Problem with MySQL encodings, how to solve?
There is a server (not Web), it has MySQL locally. When a message comes from the client to the server, the server checks it and writes it to MySQL, but the trouble is, sometimes messages with special messages come. characters or Cyrillic, and when writing to MySQL, all such characters are replaced by question marks, i.e. incorrectly.
At first, the server itself and the database were locally with me (while debugging) - everything was in order, the database itself was encoded in UTF-8 and the server with the client on it, but after importing to a remote server, the problem described above appeared. When importing, the database dump specified UTF-8 encoding for each table.
Before sending any strings to the database, I specify the encoding of these strings.
How is this decided?
UPD.
UPD 2.
Server in Java, I use Jdbc to connect.
UPD 3. locale command
Answer the question
In order to leave comments, you need to log in
I fixed everything, adding these lines to /etc/mysql/my.cnf helped:
[client]
default-character-set = utf8
[mysqld_safe]
default-character-set = utf8
[mysqld]
character-set-server = utf8
collation-server = utf8_general_ci
init-connect = "set names utf8;"
[mysqldump]
default-character-set = utf8
Most likely the problem is not with mysql, but with the locale of the server itself, show the output of the locale command on the server and if it is not UTF-8, change the locale.
This means that PHP uses the incorrect encoding - latin. After creating the MySQL object and sending queries to PHP, execute the SQL:SET NAMES UTF8
From clients in what coding the message comes? If it's not utf-8 do you convert?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question