Why can't mysql insert data?-php Tutorial

Source: Internet
Author: User
Tags mysql insert
Why can't mysql insert data? After AppServ is installed, mysql is used for the first time. There is no graphical interface. the following operations are performed on "MySql & nbsp; Command & nbsp; Line & nbsp; Client": Why cannot mysql insert data?
After AppServ is installed, mysql is used for the first time. There is no graphical interface. the operations on "MySql Command Line Client" are as follows:
========================================================== ========================================================== ======
Mysql> create database cars;
Query OK, 1 row affected (0.00 sec)

Mysql> use cars;
Database changed
Mysql> create table cars (id int, xm char (8), h char (8), vin char (20 ));
Query OK, 0 rows affected (0.06 sec)

Mysql> insert into cars (id, xm, h, vin) values (1, 'Lian Dongfang ', 'Yu A5F568', 'ldc666l2980790000 ');
Query OK, 1 row affected, 1 warning (0.02 sec)

Mysql> select * from cars;
+ ------ + ---------- + ------------------- +
| Id | xm | h | vin |
+ ------ + ---------- + ------------------- +
| 1 | Yu A5F568 | LDC666L2980790000 |
+ ------ + ---------- + ------------------- +
1 rows in set (0.02 sec)

Mysql> select xm from cars;
+ ------ +
| Xm |
+ ------ +
|
+ ------ +
1 rows in set (0.00 sec)

Mysql> update cars set xm = 'Lian 'where id = 1;
Query OK, 0 rows affected, 1 warning (0.01 sec)
Rows matched: 1 Changed: 0 Warnings: 0

Why cannot I set the value of the xm field? Why cannot I update it? Thank you ~~~


------ Solution --------------------
Your #1 content is only visible after I reply to #3. Otherwise, it will be explained at the beginning.

\ XC1 \ xAE \ xB6 \ xAB \ xB7 \ xBD is the gbk internal code of Lian Dongfang.
However, he reported an error. This indicates that the default character set of your database is not latin1 or gbk.
So the Chinese error can only be utf8 (very few people with UCS-2, even it does not matter)

If you insert gbk characters into the utf8 field, an error is returned.
Therefore, set names gbk to notify mysql that the gbk character is used now.

Why did "yu" not report an error?
This depends on how UTF-8 is encoded:
U + 007F 0 xxxxxxx
U + 07FF 110 xxxxx 10 xxxxxx
U + FFFF 1110 xxxx 10 xxxxxx 10 xxxxxx
U + 1 FFFFF 11110xxx 10 xxxxxx 10 xxxxxx 10 xxxxxx
U + 3 FFFFFF 111110xx 10 xxxxxx 10 xxxxxx 10 xxxxxx 10 xxxxxx
U + 7 FFFFFFF 1111110x 10 xxxxxx 10 xxxxxx 10 xxxxxx 10 xxxxxx

Yu's gbk binary internal code is 11010100 10100101
It is in line with the U + 07FF encoding rules, so he will not report an error

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.