The dreaded MySQL import encoding issue - revisited

admin

Administrator
Staff member
I'm having the standard MySQL import encoding issue, but I can't seem to solve it.

My client has had a WordPress installation running for some time. I've dumped the database to a file, and imported it locally. The resulting pages have a splattering of � characters throughout.

I've inspected the database properties on both sides:
production: show create database wordpress;

Code:
CREATE DATABASE `wordpress` /*!40100 DEFAULT CHARACTER SET latin1 */

local: show create database wordpress;

Code:
CREATE DATABASE `wordpress` /*!40100 DEFAULT CHARACTER SET latin1 */

production: show create table wp_posts;

Code:
CREATE TABLE `wp_posts` (
  `ID` bigint(20) unsigned NOT NULL auto_increment,
  ...
  KEY `post_date_gmt` (`post_date_gmt`)
) ENGINE=MyISAM AUTO_INCREMENT=7932 DEFAULT CHARSET=utf8

local: show create table wp_posts;

Code:
CREATE TABLE `wp_posts` (
  `ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  ...
  KEY `post_date_gmt` (`post_date_gmt`)
) ENGINE=MyISAM AUTO_INCREMENT=7918 DEFAULT CHARSET=utf8

I've spent hours reading forums on how to squash the �, but I can't get anything to work. 99% of the answers say to match the character set between the databases. What I think should work if the following:

Code:
mysqldump --opt --compress --default-character-set=latin1 -uusername -ppassword wordpress | ssh [email protected] mysql --default-character-set=latin1 -uusername -ppassword wordpress

I've done it using the utf8 char-set as well. Still with the �'s.

I've tried modifying the SQL dump directly, putting with <em>utf8</em> or <em>latin1</em> in the "SET names UTF8" line. Still with the �'s.

<strong>Strange Symptoms</strong>

I'd expect these � characters to appear in place of special characters in the content, like <em>ñ</em> or <em>ö</em>, but I've seen it where there would normally be just a space. I've also seen it in place of apostrophes (<em>but not all apostrophes</em>), double quotes, and trademark symbols.

The � marks are pretty rare. They appear on average three to four times per page.

I don't see any �'s when viewing the database through Sequel Pro (locally or live). I don't see any �'s in the SQL when viewing through Textmate.

What am I missing?

<strong>EDIT</strong>

More info:

I've tried to determine what the live database thinks the encoding is. I ran
Code:
show table status
, and it seems that the Collations are a mix of
Code:
utf8_general_ci,
utf8_bin
Code:
and
latin1_swedish_ci`. What are they different? Does it matter?

I also ran:
Code:
show variables like "character_set_database"
and got
Code:
latin1
;