mysql版本:5.0.27
安装mysql时,由于失误导致mysql默认编码为latin1,这样导致中文支持不了,遂想修改mysql编码为utf8。
步骤如下:
一、管理工具-->服务-->停掉mysql服务
二、修改my.ini配置文件:
1.在[client]的port=3306的下面一行添加default-character-set=utf8
2.将[mysql]中的default-character-set=latin1中的latin1改为utf8
3. 将[mysqld]中的default-character-set=latin1中的latin1改为utf8
三、重启mysql服务
service mysqld restart
四、进入mysql命令行,输入以下命令检查
mysql> show variables like 'character_set_%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
mysql> show variables like 'collation_%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+
文章参考:http://blog.chinaunix.net/u/16288/showart_1949661.html
版权声明:本文为博主原创文章,未经博主允许不得转载。