Play MySQL Linux under modify default encoding

Source: Internet
Author: User
Tags mysql command line

The younger brother here recorded the MySQL default code modification, here will its default code all unify changes to UTF8, hoped this article has the help to everybody, thanks!

Environment:

Linux version: Centeros 6.6 (demo below), Ubuntu 12.04 (see the article at the end of the Red label font)

MySQL version: 5.1.73

First go to the MySQL command line interface, you can see my another article: play MySQL Linux simple operation

Then view the default code for MySQL,

Enter the command: Show variables like '%character% ';

Example diagram:


Next exit the MySQL input command: Exit, or use another terminal to switch to administrator status.

There are several ways to modify here, the younger brother know two, one is here this man's method, address: http://www.2cto.com/database/201204/127849.html

Little brother's system inside originally exists above said/etc/my.cnf file, so there is no replacement, but directly in the/etc/my.cnf file inside modify. In fact, the principle is the same, with the man's replacement modification method is to set the MySQL startup parameters, and the younger brother's method is simple to use the existing file simple setup parameters.

Then go into the MySQL configuration file/etc/my.cnf inside to make changes,

Enter the command: vim/etc/my.cnf

Example diagram:


Add the following code where the yellow marker is

Default-character-set=utf8

init_connect= ' SET NAMES UTF8 '

[Client]

Default-character-set=utf8

Explain:

The first two sentences are to modify the default encoding for the server, and the last two to set the client's default encoding.

init_connect= ' Set NAMES UTF8 ' (set to use UTF8 encoding when connecting to the MySQL database to allow the MySQL database to run as UTF8), this line of code can be added.

Complete the following:


Then restart the MySQL service and go inside MySQL

Enter the command:

Service mysqld Restart

mysql–uroot–p123456 (123456 for password, or can be removed, hidden password input)

Then enter the command to see if the default encoding changes

Enter the command: Show variables like '%character% ';

The result of the modification is as follows:


Note: The above are all modified under the Center OS system, the configuration file modified under Ubuntu system is not/etc/my.cnf, but/etc/mysql/my.cnf, the modification process as shown above, the modified file


Then restart the MySQL service, go to MySQL and check the code to see that it has changed.

Reprint Please specify source: http://blog.csdn.net/yannanying/article/details/43087049

Play MySQL Linux under modify default encoding

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.