SET NAMES
SET NAMES
indicates what character set the client will use to send SQL statements to the server. That means that SET NAMES 'cp1251'
tells the server “future incoming messages from this client are in character set cp1251.” It also specifies the character set that the server should use for sending results back to the client.
SET CHARACTER SET
SET CHARACTER SET
is similar to SET NAMES
, but sets character_set_connection
and collation_connection
to character_set_database
and collation_database
. A SET CHARACTER SET x
statement is equivalent to these three statements:
SET character_set_client = x;
SET character_set_results = x;
SET collation_connection = @@collation_database;
Do both commands need to be issued in order to make MySQL UTF-8 aware? Or is SET NAMES enough?
SET NAMES is enough.