mysql5.7 Coded Unified Utf-8

Source: Internet
Author: User

To view the MySQL database encoding:

Show variables like ' character% ';

Mysql> Show variables like'character%';+--------------------------+-------------------------------------------------+| variable_name | Value |+--------------------------+--------------------------------------------- ----+| character_set_client | GBK | | character_set_connection | GBK | | Character_set_database | Latin1 | | Character_set_filesystem | binary | | Character_set_results | GBK | | Character_set_server | Latin1 | | Character_set_system | UTF8 | | Character_sets_dir | E:\0Develop\mysql-5.7. the-winx64\share\charsets\ |+--------------------------+-------------------------------------------------+8Rowsinch Set,1Warning (0.00sec) MySQL>

It can be seen that both database and server are LATIN1 encoded and do not support Chinese, we need to modify it to utf-8.

In addition to these two, the others are as follows:

| 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       | E:\0Develop\mysql-5.7. -winx64\share\charsets\

In the MySQL installation directory, save the My-default.ini copy as My.ini
Make the following changes :

Mainly look at the contents of the Red box:

[Mysqld]character-set-server=UTF8 collation-server=utf8_general_ci [MySQL] default-character-Set = Utf8[mysql.server]default-character-Set = Utf8[mysqld_safe] default-character-Set = utf8[client]default-character-set = UTF8

Then delete your current MySQL service and re-register the MySQL service
Note: Be sure to run DOS commands with administrator privileges, and CD to the bin directory in the MySQL installation directory before registering the MySQL service

C:\windows\system32>SC Delete MYSQL[SC] DeleteService success C:\Windows\system32>e:cde:\>CD E:\0Develop\mysql-5.7. the-Winx64\bine:\0develop\mysql-5.7. the-winx64\bin>mysqld--install MySQL--defaults-file="E:\0Develop\mysql-5.7.15-winx64\my.ini"The service already exists!The current server Installed:e:\0develop\mysql-5.7. the-winx64\bin\mysqld Mysqle:\0develop\mysql-5.7. the-winx64\bin>net stop Mysqlmysql service is stopping: The service name is not valid. Please type NET helpmsg2185to get more help. E:\0Develop\mysql-5.7. the-winx64\bin>mysqld--install MySQL--defaults-file="E:\0Develop\mysql-5.7.15-winx64\my.ini"Service successfully installed. E:\0Develop\mysql-5.7. the-winx64\bin>

Results

To start the service, view the encoding:

C:\windows\system32>net start Mysqlmysql service is starting. The MySQL service has started successfully. C:\Windows\System32>mysql-u rootwelcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is 2Server Version:5.7. theMySQL Community Server (GPL) Copyright (c) -, ., Oracle and/or its affiliates. All rights reserved. Oracle isA registered trademark of Oracle Corporation and/or Itsaffiliates. Other names trademarks of their respectiveowners. Type'Help ;'Or'\h'  forHelp. Type'\c'To clear the current input statement.mysql> Show variables like'character%';+--------------------------+-------------------------------------------------+| 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 | E:\0Develop\mysql-5.7. the-winx64\share\charsets\ |+--------------------------+-------------------------------------------------+8Rowsinch Set,1Warning (0.00sec) MySQL>
DB Instance encoding settings:
Mysql>Show create database test;+----------+-----------------------------------------------------------------+| Database | Create Database |+----------+--------------------------------------------- --------------------+| Test | CREATE DATABASE ' Test '/*!40100 DEFAULT CHARACTER SET latin1*/|+----------+-----------------------------------------------------------------+1Rowinch Set(0.00sec) MySQL> ALTER DATABASE TestdefaultCharacterSetUTF8; Query OK,1Row affected (0.00sec) MySQL>Show create database test;+----------+---------------------------------------------------------------+| Database | Create Database |+----------+----------------------------------------------- ----------------+| Test | CREATE DATABASE ' Test '/*!40100 DEFAULT CHARACTER SET UTF8*/|+----------+---------------------------------------------------------------+1Rowinch Set(0.00sec) MySQL>

Reference: http://blog.csdn.net/u013474104/article/details/52486880

mysql5.7 Coded Unified Utf-8

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.