Solutions for storing Chinese data in MySQL database

Source: Internet
Author: User

I am learning Django in the admin module, login into the background operation page, input Chinese data, but after saving all is garbled (all is "?????????????????????????????? ") and then start the road to solving the problem.

1, first Baidu Search, the most mainstream method is once and for all: Modify the MySQL configuration file My.ini. I did it in this way, but the search method is not detailed, or not suitable for the new version of MySQL.

2, in the MySQL root directory to find the My.ini configuration file, but I installed the MySQL-5.6.30, in the root directory only found My-default.ini files. Rename the My-default.ini to My.ini and add the following statement in the file in [MySQL] and [client] in the following format:

== utf8[client]default-character-set = UTF8

3. Add the path to the PATH environment variable after the root path of MySQL and the root path of the bin. (This step can be ignored if the path to MySQL has not changed, if it was previously set)

4. Run the cmd command line with administrator privileges, perform the following steps, install or reinstall MySQL (note the difference between Red mysqld and black MySQL):

4.1. If you have previously installed MySQL, you need to uninstall MySQL and execute it on the command line:mysqld --remove

4.2. Execution:mysqld --install

4.3. Execute: net start MySQL

4.4, Login Mysql:mysql-u root-p

4.5, in the command line operation of MySQL, input: show variables like ' charac% ';

Displays the results as shown in the MySQL database, where the Chinese data can be stored normally.

  Note: 1, in the 2nd step, you can not put the following setting options

default-character-set = UTF8

Placed in

[Mysqld]

In the module. If so, in the process of installing or reinstalling MySQL, 4.1 and 4.2 can be executed correctly, but the error will be reported when executing 4.3:

  2 . My MySQL database displays the default configuration results before modifying the encoding configuration (although different versions of the default configuration may not be the same):

    


    


    

Solutions for storing Chinese data in MySQL database

Related Article

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.