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