How to modify Mysql code under Linux _mysql

Source: Internet
Author: User
Tags mysql code

After the default login to MySQL, you can view the system variables and their values through the show variables statement.

Mysql> Show variables like '%character% ';

Description: The following are the settings under CentOS-6.2 (different versions may vary, such as the location of the file.) But the contents of the setting should be the same)

1. Find the MySQL configuration file, copy to the ETC directory, the first step is very important

Copy the/usr/share/doc/mysql-server-5.1.52/my-large.cnf to the/ETC/MY.CNF.

Use command: CP/USR/SHARE/DOC/MYSQL-SERVER-5.1.52/MY-LARGE.CNF/ETC/MY.CNF

2. Open MY.CNF Modify Code

Increase Default-character-set=utf8 under [client]

Increase the Default-character-set=utf8 under [mysqld]

  At the same time, plus init_connect= ' Set NAMES UTF8 ' (set to connect the MySQL database with the UTF8 encoding, so that the MySQL database to run UTF8)

3. Restart MySQL

Service mysqld Restart

Enter show variables like '%character% ' again;

Even if you do the above changes if the direct database to create a table, and then stored in Chinese, will be taken out of the question mark. The solution is to specify that the default character set is UTF8 when the database is created, such as:

Create DATABASE test default character set UTF8;

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.