Analysis of the garbage problem occurs when the python automated test version of a database query data mysql5.0

1, ensure that the database encoding is utf8 encoding. If not, please my.ini the client, mysql, mysqld adding the following three fields default-character-set = utf8, which can permanently change the new database at the time of encoding utf8. Mysql service and then re-enter into the database, enter the show variables like 'char%', to see whether the change to utf8. After modification, you later when the new library is the default utf8 encoding, the data can be inserted into Chinese.

2. Check your database is not utf8 encoding, enter the show create database database name. If not, modify the database encoding, enter the name of the database ALTER DATABASE DEFAULT CHARACTER SET utf8, change the existing database coding

3. Check your data table is not utf8 encoding, enter the show create table table name. If not, modify the code table, enter the name of the database ALTER TABLE DEFAULT CHARACTER SET utf8, change the existing code table

4. Upon completion of these three steps, you can insert data have Chinese, but when you query data or distortion, because the encoding cmd in gbk, not temporary data in the table is garbled when you modify database coding, so to temporarily modify the input set names gbk, query the data again to the normal display Chinese

 

Guess you like

Origin www.cnblogs.com/vevian/p/11106753.html