How to modify MySQL character set in Liunx

Source: Internet
Author: User

The following describes how to modify the MySQL character set under Liunx. If you have encountered similar problems in the MySQL Character Set, take a look.

1. Find the cnf File Location of MySQL
Find/-iname '*. cnf'-print

/Usr/share/mysql/my-innodb-heavy-4G.cnf.
/Usr/share/mysql/my-large.cnf.
/Usr/share/mysql/my-small.cnf.
/Usr/share/mysql/my-medium.cnf.
/Usr/share/mysql/my-huge.cnf.
/Usr/share/texmf/web2c/texmf. cnf
/Usr/share/texmf/web2c/mktex. cnf
/Usr/share/texmf/web2c/fmtutil. cnf
/Usr/share/texmf/tex/xmltex/xmltexfmtutil. cnf
/Usr/share/texmf/tex/jadetex/jadefmtutil. cnf
/Usr/share/doc/MySQL-server-community-5.1.22/my-innodb-heavy-4G.cnf
/Usr/share/doc/MySQL-server-community-5.1.22/my-large.cnf
/Usr/share/doc/MySQL-server-community-5.1.22/my-small.cnf
/Usr/share/doc/MySQL-server-community-5.1.22/my-medium.cnf
/Usr/share/doc/MySQL-server-community-5.1.22/my-huge.cnf

2. Copy small. cnf, my-medium.cnf, my-huge.cnf, one of the my-innodb-heavy-4G.cnf to/etc, named my. cnf
Cp/usr/share/mysql/my-medium.cnf/etc/my. cnf

3. modify my. cnf
Vi/etc/my. cnf
Add under [client]
Default-character-set = utf8
Add under [mysqld]
Default-character-set = utf8

4. Restart MySQL
[Root @ bogon ~] #/Etc/rc. d/init. d/mysql restart
Shutting down MySQL [OK]
Starting MySQL. [OK]
[Root @ bogon ~] # Mysql-u root-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 1
Server version: 5.1.22-rc-community-log MySQL Community Edition (GPL)
Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.

5. View Character Set settings
Mysql> show variables like 'collation _ % ';
+ ---------------------- + ----------------- +
| Variable_name | Value |
+ ---------------------- + ----------------- +
| Collation_connection | utf8_general_ci |
| Collation_database | utf8_general_ci |
| Collation_server | utf8_general_ci |
+ ---------------------- + ----------------- +
3 rows in set (0.02 sec)
Mysql> show variables like 'character _ set _ % ';
+ -------------------------- + ---------------------------- +
| 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 |/usr/share/mysql/charsets/|
+ -------------------------- + ---------------------------- +
8 rows in set (0.02 sec)
Mysql>
 

The preceding section describes how to modify the MySQL character set in Liunx.

Take you to understand mysql Variables

MySQL user permission setting method

Troubleshooting of MySQL query timeout

How to process MySQL record duplication

How to query time periods in MySql

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.