In MySQL, what is the difference between doing:
SET NAMES 'utf8'
And:
SET CHARACTER SET 'utf8'
I’ve taken a look at Connection Character Sets and Collations MySQL documentation page but I’m still a bit confused… Do both commands need to be issued in order to make MySQL UTF-8 aware? Or is SET NAMES enough?
SET NAMES
SET NAMESindicates what character set the client will use to send SQL statements to the server. That means thatSET 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 SETis similar toSET NAMES, but setscharacter_set_connectionandcollation_connectiontocharacter_set_databaseandcollation_database. ASET CHARACTER SET xstatement is equivalent to these three statements:SET NAMES is enough.