Mysql garbled solution _ MySQL

Source: Internet
Author: User
Tags python mysql
Mysql garbled solution: display the character set and change the corresponding character set to utf8

Show variables like "% char % ";

+ -------------------------- + --------------- +
| Variable_name | Value |
+ -------------------------- + --------------- +
| Character_set_client | gbk |
| Character_set_connection | gbk |
| Character_set_database | utf8 |
| Character_set_filesystem | binary |
| Character_set_results | gbk |
| Character_set_server | utf8 |

| Character_set_system | utf8 |

For example

SET character_set_client = 'utf8 ';
SET character_set_connection = 'utf8 ';
SET character_set_results = 'utf8'

When creating a table:

Create table video_author (
Sid bigint (11) not null AUTO_INCREMENT,
Nick varchar (64) not null,
Url 'varchar (128) not null,
Video_type set ('Dota ', 'Lol', 'hearthstone '),
Primary key (sid ),
KEY index_name (nick)
)ENGINE = InnoDB default charset = utf8;

If you are using a python mysql connection, you also need to set charset during the connection, for example:

Self. conn = MySQLdb. connect (host = "127.0.0.1", user = "root", passwd = "000", db = "app_db", port = 3306,Charset = 'utf8')

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.