How to modify the encoding of fields in tables and tables in MySQL database _ MySQL

Source: Internet
Author: User
The method for modifying the encoding of fields in tables and tables in MySQL database adds Chinese data to a table in MySQL database today, but there is always an exception. check the program for no errors, later, I checked the table again and found that the encoding method of the table was latin1 and the encoding method of the field that I originally wanted to insert Chinese characters into was also latin1. then I checked the exceptions in the console again, further confirmation is caused by improper field encoding in the table and table. modify the corresponding field in the table and find it online for a while, after the SQL script is executed, it can be saved to Chinese characters. However, we still think that it is necessary to sum up, the ancients cloud: good memory is not as good as bad writing.

Modify the TABLE encoding method: alter table 'test' default character set utf8; this command is used to change the TABLE test encoding method to utf8;

Modify the Field Encoding method: alter table 'test' CHANGE 'name' VARCHAR (36) character set utf8 not null; this command is used to change the name field encoding method in the test table to utf8.

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.