MySQL Classic questions:
(ERROR 1366 (HY000): Incorrect string value: ' Xd5xd4 ' for column ' name ' at row 1)
There are a lot of online to solve Chinese garbled paste, roughly speaking is to modify%mysql_dir%/my.ini DEFAULT-CHARACTER-SET=GBK or something
I tried, and it didn't work. (may be I did not handle in place)
Here is what I have been thinking about for a long time, the results, I do not know whether it is worth advocating, but the purpose is absolutely achieved:
Login to MySQL--->
Enter the appropriate database--->
Input command: Show variables like '%char% ';
Get:
+--------------------------+--------------------------+
| variable_name | Value |
+--------------------------+--------------------------+
| Character_set_client UTF8
| Character_set_connection UTF8
| Character_set_database latin1
| Character_set_filesystem binary
| Character_set_results UTF8
| Character_set_server UTF8
| Character_set_system UTF8
| Character_sets_dir d:mysqlsharecharsets
+--------------------------+--------------------------+
If this happens, you need to change the database encoding: two methods, the first one is a fix, the second is only valid for the current connection, disconnect, and revert to the state before the change
Methods 1:alter database name CharSet UTF8;
Methods 2:set character_set_database = UTF8;
Again with the command: show variables like '%char% ';
+--------------------------+--------------------------+
| variable_name | Value |
+--------------------------+--------------------------+
| Character_set_client UTF8
| Character_set_connection UTF8
| Character_set_database UTF8
| Character_set_filesystem binary
| Character_set_results UTF8
| Character_set_server UTF8
| Character_set_system UTF8
| Character_sets_dir d:mysqlsharecharsets
+--------------------------+--------------------------+
The encoding is already consistent, but inserting Chinese characters into the tables in the database will still report: ERROR 1366 (HY000)
---> Set character_set_client = GBK; Sets the encoding to be received at the time of insertion as GBK, so that you can insert Chinese
At this point, the Chinese characters can be inserted, but the query result is still garbled, and then change a place can:
---> Set character_set_results = GBK; The encoding of the output result is GBK
Note: This setting is only related to the current connection, disconnect, these settings restore the database default settings state, so if necessary, each connection must be set!
In addition: Error 1366 (HY000) errors occur mainly when the console (cmd/Black window) executes SQL statements to insert Chinese.
Insert with Mysql-front software does not report character problems, Java through JDBC Connection database execution executeupdate ("INSERT statement") Chinese can also successfully insert data and no error!
PHP to solve the garbled problem only in the connection after joining Mysql_query ("Set names ' GBK '") on the ok!
such as: $conn = mysql_connect ("localhost", "root", "");
mysql_query ("Set names ' GBK '");