Loading UTF-8 encoded dump into MySQL

前端 未结 3 1709
无人及你
无人及你 2021-02-06 04:18

I\'ve been pulling my hear out over this problem for a few hours yesterday:

I\'ve a database on MySQL 4.1.22 server with encoding set to \"UTF-8 Unicode (utf8)\" (as rep

相关标签:
3条回答
  • 2021-02-06 05:07

    SOLUTION for me:

    set this option in your php file, after mysql_connect (or after mysql_select_db)..

    mysql_query("SET NAMES 'utf8'");
    
    0 讨论(0)
  • 2021-02-06 05:16

    Ugh... ok, seems I found a solution.

    MySQL isn't the culprit here. I did a simple dump and load now, with no changes to the dump.sql script - meaning I left "set names latin2" and tables charsets as they were. Then I switched my original CMSMS installation over to the new database and... it worked correctly. So actually encoding in the database is ok, or at least it works fine with CMSMS installation I had at my old hosting provider (CMSMS apparently does funny things with characters encoding).

    To make it work on my new hosting provider, I actually had to add this line to lib/adodb/drivers/adodb-mysql.inc.php in CMSMS installation:

    mysql_query('set names latin2',$this->_connectionID);

    This is a slightly modified solution from this post. You can find the exact line there as well. So it looks like mysql client configuration issue.

    0 讨论(0)
  • 2021-02-06 05:21

    Did you try adding the --default-character-set=name option, like this:

    mysql --default-character-set=utf8 -h ffffd -u zzz -p dbname < dump.sql
    

    I had that problem before and it worked after using that option.

    Hope it helps!

    0 讨论(0)
提交回复
热议问题