Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7021953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:31:02+00:00 2026-05-27T23:31:02+00:00

I’m having the standard MySQL import encoding issue, but I can’t seem to solve

  • 0

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;

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

local: show create database wordpress;

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

production: show create table wp_posts;

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;

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:

mysqldump --opt --compress --default-character-set=latin1 -uusername -ppassword wordpress | ssh username@anotherserver.net 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 utf8 or latin1 in the “SET names UTF8” line. Still with the �’s.

Strange Symptoms

I’d expect these � characters to appear in place of special characters in the content, like ñ or ö, but I’ve seen it where there would normally be just a space. I’ve also seen it in place of apostrophes (but not all apostrophes), 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?

EDIT

More info:

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

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:31:02+00:00Added an answer on May 27, 2026 at 11:31 pm

    This is how I ended up solving my problem:

    First mysqldump -uusername -ppassword --default-character-set=latin1 database -r dump.sql

    Then run this script:

    $search = array('/latin1/');
    $replace = array('utf8');
    foreach (range(128, 255) as $dec) {
        $search[] = "/\x".dechex($dec)."/";
        $replace[] = "&#$dec;";
    }
    
    $input = fopen('dump.sql', 'r');
    $output = fopen('result.sql', 'w');
    
    while (!feof($input)) {
        $line = fgets($input);
        $line = preg_replace($search, $replace, $line);
        fwrite($output, $line);
    }
    
    fclose($input);
    fclose($output);
    

    The script finds all the hex characters above 127 and encoded them into their HTML entities.

    Then mysql -uusername -ppassword database < result.sql

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.