I know there are many settings for a language for a table and a database.
I already created the database. I believe when I created it, it was default/LATIN. I want to change everything-I mean...both the table and the database, to UTF-8.
How can I do that? thanks.
aioobe's answer tells how to change the character set of a database, table or column. You should keep in mind that
setting the character set for a table just specifies the default character set for new columns in that table. It doesn't change the character set for preexisting columns; you have to do those columns individually, OR if you want to change every single string-type column in the table to the same character set there's a command you can use to do that: "alter table ... convert to character set" ( http://dev.mysql.com/doc/refman/5.1/en/alter-table.html )
if you already have data that is stored mis-encoded in a column, then using "alter table ... modify" to change the column will not quite solve the problem. For example, if you're been storing UTF-8 data in a Latin1 column and you change the character set directly from Latin1 to UTF-8, it'll still be mis-encoded afterwards. This can be worked around by converting from Latin-1 to UTF-8 via binary.
Add to your my.cnf this:
And restart mysqld deamon.
ADDED:
and my.cnf
Have a look at Using alter command to change character set.
Another useful link: http://dev.mysql.com/doc/refman/5.0/en/charset-table.html
The general form is
and for a specific column in a table
1) Database default character set and collation:
Altered via:
ALTER DATABASE CHARACTER SET utf8 COLLATE utf8_general_ci;
2) Table default character set and collation:
Altered via:
ALTER TABLE [table_name] CHARACTER SET utf8 COLLATE utf8_general_ci
3) Column character set and collation:
Altered via:
ALTER TABLE [table_name] CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci
The third one requires that you disable foreign key checks for the data conversion. So putting this all together:
EDIT: look here instead