1、查看mysql数据库的编码:
mysql> show variableslike'char%';
+--------------------------+-----------------------------------+
| Variable_name| Value|
+--------------------------+-----------------------------------+
| character_set_client| gb2312|
| character_set_connection | gb2312|
| character_set_database| utf8|
| character_set_filesystem | binary|
| character_set_results| gb2312|
| character_set_server| utf8|
| character_set_system| utf8|
| character_sets_dir| D:\MySQLServer5.0\share\charsets\ |
+--------------------------+-----------------------------------+
8 rows in set (0.05 sec)
mysql> show variableslike'coll%';
+----------------------+-------------------+
| Variable_name| Value|
+----------------------+-------------------+
| collation_connection | gb2312_chinese_ci |
| collation_database| utf8_general_ci|
| collation_server| utf8_general_ci|
+----------------------+-------------------+
3 rows in set (0.00 sec)
2、设置mysql数据库的编码
编码可以再/etc/my.cnf中更改改完后重新启动。
例如:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for
compatibility with mysql 3.x
# clients (those using the mysqlclient10
compatibility package).
old_passwords=1
default_character_set=utf8 #添加的内容
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
##########confluence##############
#default_character_set=utf8
character_set_server=utf8
一定要放到mysqld模块下