php连mysql用 utf-8编码乱码怎么办

php连mysql用 utf-8编码乱码怎么办

1.修改my.ini:[mysql]default-character-set=utf8[mysqld]default-character-set=utf8default-storage-engine=MyISAM在[mysqld]下加入:default-collation=utf8_bininit_connect='SET NAMES utf8'

2.在需要做数据库操作的php程序前面加上mb_internal_encoding('utf-8');

3.create table最后边加上ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin

4.phpMyAdmin/config.inc.php

$cfg['DefaultCharset'] = 'utf-8';$cfg['RecodingEngine'] = 'iconv';

5.phpMyAdmin/libraries/string.lib.php将第41行的mb_internal_encoding($GLOBALS['charset']);改为:mb_internal_encoding('utf-8');

6.phpAdmin导出数据时把"二进制区域使用十六进制显示"的勾去掉