[resolved] Easier way to convert database charset from latin1 to utf8 ? (2 posts)

  1. ymf
    Posted 2 years ago #

    I discovered that in my database I have a mix of 10 legacy latin1_swedish_ci-collated tables (DEFAULT CHARSET=latin1) and some new utf8_general_ci-collated tables (DEFAULT CHARSET=utf8). A symptom is that foreign (e.g. Cyrillic) characters in posts and comments are displayed as question marks. The config file contains

    define('DB_CHARSET', 'utf8');
    define('DB_COLLATE', '');

    I'd like to convert the database to only use the new utf8_general_ci-collated tables (DEFAULT CHARSET=utf8). I found a codex guide http://codex.wordpress.org/Converting_Database_Character_Sets with elaborate, and presumably correct, instructions.

    I wonder, is that the only reliable way? Or is there an easier way to convert database charset from latin1 to utf8 ?

    E.g. when I look at the database's backed up SQL file, it contains fragments like this:

    DROP TABLE IF EXISTSwp_comments;
    /*!40101 SET @saved_cs_client = @@character_set_client */;
    /*!40101 SET character_set_client = utf8 */;
    CREATE TABLE wp_comments (
    /*!40101 SET character_set_client = @saved_cs_client */;

    What if I change in the these fragments the keywords "latin1" to "utf8" and restore the database?

  2. ymf
    Posted 2 years ago #

    Problem solved via database export - tweaking the dump - dropping the database - database import. It's the same method as one proposed in Alex King's blog about latin1 to utf8 conversion.

Topic Closed

This topic has been closed to new replies.

About this Topic