Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I've been reading through the MySQL docs on character encodings recently but I'm getting hung up on character_set_results and character_set_connection.

I understand that character_set_client tells the server what character set to expect from the client. So, if I set this to utf8, then I need to make sure that the data I'm sending is actually encoded to utf8.

However, I have the following related questions:

#1) character_set_connection

The docs indicate that the server will actually convert the incoming data received from the client to this character set.

So, say I send latin1, and I have character_set_client set to latin1 as well. However, the field being inserted is UTF-8. Do I need to set character_set_connection to UTF-8 to first convert the data to UTF-8? MySQL won't automatically do the conversion when I try and insert latin1 data into a utf8 field?

#2) field encoding settings

Related to above, what does the field encoding setting actually do? Does it actually perform any transformations when the incoming encoding does not match this encoding?

#3) character_set_results

The description is "indicates the character set in which the server returns query results to the client. This includes result data such as column values, and result metadata such as column names." Why is this needed? Why wouldn't the server just look at the character encoding of the field/table/database/server and use that encoding?

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.