The question is not quite right. You need to specify the character set encoding in two places: The bytes on the client and the bytes on the server.
Client encoding
Best: Establish the in/out character set via connection parameters. There you specify the encoding of the client.
Second best is SET NAMES utf8mb4;
right after connecting (assuming you want utf8mb4
).
Server encoding
The charset on each column (in the database) comes from the column definition. If missing, then the default comes from the table definition. Run SHOW CREATE TABLE
.
If client and server are not the same, MySQL will transcode when INSERTing
and when SELECTing
.
If you have specific symptoms, see Trouble with UTF-8 characters; what I see is not what I stored