1

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

7
  • Off-topic for SO; belongs on Database Administrators – Jim Garrison Oct 27 '12 at 6:02
  • What is the default collation for your database? – Mike Brant Oct 27 '12 at 6:06
  • My default character set is utf8 and my collate is utf8_general_ci. – Robert Ruby II Oct 27 '12 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 Oct 27 '12 at 16:31
  • If you really found an answer, please, answer your question in a proper answer. You can even accept it afterwards. – dezso Oct 27 '12 at 17:45
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.