Phpmysql table Chinese garbled problem how to solve

Source: Internet
Author: User
Phpmysql table Chinese garbled problem how to solve

  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 parameters;

You can also specify the gbk encoding when creating a table.

Of course, you can also use the following command to modify the character set of the database:

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

The client sends data in gbk format. the following configurations can be used:

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

The above describes how to solve the problem of Chinese garbled characters in data tables in pyh mysql programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.