Why Are My WordPress Searches Case-Sensitive?

Playing around with my WordPress installation, I noticed when searching for certain terms, the search results returned were case-sensitive, even though according to the documentation, neither WordPress nor MySql are, by default.

A few Google searches later and I found the reason: trying to be clever, I’d set the database’s collation to utf8_bin which is case-sensitive. The solution should be an easy one, just change the collation to something like utf8_general_ci (ci stands for case-insensitive), not forgetting to update the collation setting in wp-config.php too.

That didn’t quite do it though since the tables and columns were all still collated as utf8_bin so the searches were still case-sensitive.

The Solution

You actually need to change the collation on all of your columns to utf8_general_ci or whichever collation you’ve chosen using a command such as

ALTER TABLE wp_posts CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

Although in truth just changing the collation of post_data in the wp_posts table solves the problem just fine.