MySQL character sets

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I recently upgraded from 4.0 to 4.1.  I've spent the last few days  
reading up on charsets since I never really thought about it when I used  
4.0.  I thought I had most of it figured out, but then I saw this in  
phpMyAdmin and am as confused as when I started:

MySQL charset:  UTF-8 Unicode (utf8)
MySQL connection collation: utf8-unicode-ci (in a dropdown box)

I know that with 4.1, the default charset for tables is latin1, and the  
default collation is latin1_swedish_ci.  Why would these default to  
latin1, but then my server and connection default to utf-8?  I might be  
totally off base but I would have thought the default for each would be  
the same charset...

Also, is this why queries entered into phpMyAdmin such as:

SET ...
WHERE `fieldname` = 'test'

now automatically get converted to:

SET ...
WHERE CONVERT( `fieldname` USING utf8 ) = 'test'

 From all the online documentation I have been reading, it seems that  
ideally I would convert my whole system over to use utf-8... practically  
speaking, however, I would rather not, as I really only have the need to  
store ASCII characters and after upgrading have altered my data  
validation functions to check for ASCII.  Given this and what I have  
provided above, would it be allright for me to leave everything as is  
(defaulted), or do I need to alter anything with any of my charsets?  
For example, I have not changed any of my queries to reflect the  
phpMyAdmin added syntax above, but everything seems to still work ok.  
Dealing with these charsets is still new to me, and I'm not sure what  
else I can get out of these tutorials (I currently have 34 firefox  
windows open), so I thank you all very much for any help you can provide.

- Marcus

Re: MySQL character sets

Just as a followup, I did some more reading and I think the discrepancy  
in charsets is because phpMyAdmin is using utf-8.  I ran a status query  
in mysql and see that the 4 default charsets are in fact all latin1.

This being the case, how do I check to make sure my php application is  
connecting with latin1?  I'm not really sure where to check this or how  
to set it... I only know that phpMyAdmin has a setting in it's config file.

Please correct me if anything I just typed is wrong.  And also, I still  
am not sure if the scenario I posted at the end of my initial post  
regarding latin1 instead of utf-8 for my tables is ok.  Thanks!!!

Site Timeline