What should I do if MySQL encounters Chinese garbled characters when inserting data?

零下一度
Release: 2017-06-28 10:28:47
Original
2226 people have browsed it

What should I do if MySQL encounters Chinese garbled characters when inserting data?

[Problem 1]

When using MySQL Workbench to insert data, the insertion involving strings will not work.

As follows:

Error Code: 1366. Incorrect string value: '\xE5\xBC\xA0\xE4\xB8\x89' for column 'name' at row 1

[Question 2]

In a java file written using eclipse, statements can be inserted after connecting to the database, but the inserted Chinese will be displayed as a "???" question mark in the database.

Used solutions:

1.mac uses in the terminal: PATH="$PATH" /usr/local/mysql/bin to enter mysql

Then: mysql -u root -p At this time, you will be prompted to enter the password

After completion, enter mysql

[First check the current character set of mysql]

[The second step is to set it up]

[In the second part of the setup, I encountered such a problem and changed utf8 to utf8_general_ci It can be executed]

[Check again]

[After all settings are completed, restart mysql and you should be able to insert Chinese. ]

[However, my mysql does not love me. This approach failed, but it should work for a large number of people. 】

【We are still trying other methods...】

The above is the detailed content of What should I do if MySQL encounters Chinese garbled characters when inserting data?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!