当前位置:Gxlcms > PHP教程 > phpmysql表中文乱码问题如何解决

phpmysql表中文乱码问题如何解决

时间:2021-07-01 10:21:17 帮助过:14人阅读

  1. create database zzjz CHARACTER SET gbk COLLATE gbk_chinese_ci;

  2. create table zz_employees (employeeid int unsigned not null auto_increment primary key,name varchar(13) not null,updatetime datetime) CHARACTER SET gbk COLLATE gbk_chinese_ci;

  3. create table zz_configitems(itemid int unsigned not null auto_increment primary key,itemname varchar(12) not null) CHARACTER SET gbk COLLATE gbk_chinese_ci;
  4. create table zz_items(itemid int unsigned not null ,employeeid int unsigned not null,item varchar(200) not null,primary key (itemid) ,
  5. FOREIGN KEY (itemid) REFERENCES zz_configitems(itemid) ON UPDATE CASCADE,FOREIGN KEY (employeeid) REFERENCES zz_employees(employeeid) ON UPDATE CASCADE ) CHARACTER SET gbk COLLATE gbk_chinese_ci;

也可以在创建表的时候指定gbk的编码。

当然,也可以通过如下指令修改数据库的字符集

  1. alter database da_name default character set 'charset'.

客户端以 gbk格式发送 ,可以采用下述配置:

  1. SET character_set_client='gbk'
  2. SET character_set_connection='gbk'
  3. SET character_set_results='gbk'

以上介绍了pyh mysql编程中数据表出现中文乱码问题的解决方法,希望对大家有所帮助。

人气教程排行