mysqlzhongwenluanma/ target=_blank class=infotextkey>mysql中文乱码问题:
由于mysql是从版本 4迁移到version 5的,原来字符集是latin1,现在是utf8,即使通过phpadmin来访问也是乱码。
mysql数据乱码是由于字符集的变化和混乱引起的:
[root@localhost plugins]# /mysql -hlocalhost -ueygle -p eygle
Enter password:
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)
现在的mysql字符集是utf8,但是由于原来是latin1的字符集,我使用latin1进行导出:
这样导出之后,如果打开看,正文应当都是正常显示才对,然后更改mysql字符集,将所有表的字符集设置改为utf8,在vim中的命令是:
再执行导入操作:
修改后的mysql字符集: