Today when playing a web project, encountered such a problem, go in using the insert into
command to insert a record, there is no error, but did not succeed in the database, at first I thought it was to obtain data post request is a problem, but more than after the test found no problems, repeatedly printing error, debug everywhere, but not always find the problem. When I post data after accidental lightly press the keyboard, even just a look successful, then I suddenly had the idea, I recently used linux, and did not consider the transcoding problem, but when you open the database in turn also go utf-8 yards, and that there is no problem, that's when I casually inserted into the mysql Chinese, I found no success, this find the problem. The next encounter this problem set about coding time to pay attention to create a table.
solve:
- Created when transcoding
create table entries2 (
id int auto_increment,
title text,
content text,
posted_on datetime,
primary key (id)
) character set = utf8;
- Convert existing table
alter table table_name convert to character set utf8;
Reference:
https://www.cnblogs.com/livingintruth/p/3433259.html