mysql accesses data solve the garbage problem (IDEA)

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/wy798393546/article/details/78321787

When I add or modify data garbled when a database arise
Chinese programmers feel really tired than others, because in addition to achieving business, have to consider the garbage problem. These two days have been garbled tangle of mysql, google a lot of ways, and finally a success. So to put out their own investigation process for the next reference

1. Troubleshoot idea

I thought it was a tool of reason, so do the following aspects of the work.
First three places at the same time set to utf-8
Because there may be garbled transmission from the client to the server occur, there may be transmitted from the server to the client appears. Therefore, two transmission directions are added.
In front of the code and then add these two codes

2. investigation database

View the database type:

show variables like 'character_set_%';

This is after I modified, have no right type of garbled screenshot
Prior to this, 1,2,3,5,6 row is latin1. So maybe that is the root cause.
Just started using a few of these codes:

SET character_set_client = utf8;
SET character_set_connection = utf8;
SET character_set_database = utf8;
SET character_set_results = utf8;
SET character_set_server = utf8;

Indeed it was, but when I restart the mysql appeared garbled. A check back to the original look.
This configuration file found in the mysql installation directory
To be safe, make a copy of a copy.
The original change it

Completion! ~

Guess you like

Origin blog.csdn.net/wy798393546/article/details/78321787