I am adding tables to a Wordpress database on my localhost and it is changing my collation from utf8_general_ci
to latin1_swedish_ci
. I'm kinda stumped because I'm not familiar with working directly with databases since I am new to them. Could you explain why this happens?
My default character set is utf8
and my collation is utf8_general_ci
.
Also, when I use the same code to create a table in other databases it works correctly.
HOLY CRAP I just now tried using wordpresses $wpdb class and it is doing the SAME THING! What the crap!
FOUND ANSWER AT WORDPRESS ANSWERS ---- https://wordpress.stackexchange.com/questions/5927/default-table-collation-on-plugin-activation?rq=1
-
Off-topic for SO; belongs on Database AdministratorsJim Garrison– Jim Garrison2012年10月27日 06:02:04 +00:00Commented Oct 27, 2012 at 6:02
-
What is the default collation for your database?Mike Brant– Mike Brant2012年10月27日 06:06:39 +00:00Commented Oct 27, 2012 at 6:06
-
My default character set is utf8 and my collate is utf8_general_ci.Robert Ruby II– Robert Ruby II2012年10月27日 16:16:32 +00:00Commented Oct 27, 2012 at 16:16
-
This very much so makes no sense at all. I am, using the same exact class I wrote, creating tables in other databases and it is creating them with the correct data.Robert Ruby II– Robert Ruby II2012年10月27日 16:31:03 +00:00Commented Oct 27, 2012 at 16:31
-
If you really found an answer, please, answer your question in a proper answer. You can even accept it afterwards.András Váczi– András Váczi2012年10月27日 17:45:36 +00:00Commented Oct 27, 2012 at 17:45
1 Answer 1
Finally actually adding this to the question. You must specify the COLLATION while creating the table. It will inherit the collation from the database which is latin1_swedish_ci. Wordpress sets the collation only for the connection, not for the database. E.g. for WHERE or ORDER BY clauses... See Answer and comment similar to this in link above.
hrake gets the credit not I