Mysql modifies the character set of the default environment to utf-8_MySQL

Source: Internet
Author: User
Mysql modifies the environment's default character set to UTF-8 (of course you can set it to UTF-8). First, you must turn off the mysql service in the service and then go to your mysql installation path, if mysql modifies the environment's default character set to UTF-8 (you can also set it to UTF-8)

First, you must turn off the mysql service in the service.

Then go to the installation path of your mysql instance. if it is a custom file, find the custom path. the default value is C: \ Program Files \ MySQL Server 5.0 \ my. ini.

Find the client mysql to addDefault-character-set = utf8

Add the following to mysqld: default-character-set = utf8

Init_connect = 'set NAMES utf8'

The following statement is used to check whether the encoding method has been modified:
Show variables like 'char % ';

If yes, your previous database is not configured properly:

For an existing database, you can change the encoding method as follows:
A. modify the mysql database encoding. if the mysql database encoding is incorrect, run the following command in MYSQL: alter database test default character set utf8;
The preceding command sets the encoding of MYSQL's test database to utf8.
B. modify the MYSQL TABLE encoding: ALTER TABLE category DEFAULT CHARACTER SET utf8;
The preceding command changes the category encoding of a table to utf8.
C. modify the field encoding:
Alter table 'test' CHANGE 'DD' DD' VARCHAR (45) character set utf8 COLLATE utf8_bin NOT NULL
The preceding command changes the dd field encoding in the MYSQL database test table to utf8.

The following code inserts a Chinese character in a command line:
Set names gb2312; sometimes this sentence is critical!
Insert into charset values ('lmj ');

Then restart the service.

If the service cannot be started, run cmd as an administrator to go to the mysql installation directory and run

Mysqld-remove service

Then

Mysqld-install installation service

You can.

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.