[root@localhost plugins]# /mysql -hlocalhost -ueygle -p eygle Enter password: --phpfensi.com Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1693469 Server version: 5.0.45 Source distribution type ’help;’ or ’\h’ for help. Type ’\c’ to clear the buffer. mysql> show variables like ’%char%’; +————————–+———————————-+ | Variable_name | Value | +————————–+———————————-+ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | latin1 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /opt/mysql/share/mysql/charsets/ | +————————–+———————————-+ 8 rows in set (0.00 sec) 现在的字符集是utf8,但是由于原来是latin1的字符集,我使用latin1进行导出:
mysqldump -hlocalhost -ueygle -p –default-character-set=latin1 blog >blog.sql
mysql_query("SET NAMES 'UTF8'"); mysql_query("SET CHARACTER SET UTF8"); mysql_query("SET CHARACTER_SET_RESULTS=UTF8'"); 还有个方法就是,如果你自己的机器的话,可以更改MYSQL字符集,一般在MYSQ4和MYSQL5这两个版本中有效.