How to modify the default mysql character set to utf8 in MAC, mysqlutf8

Source: Internet
Author: User

How to modify the default mysql character set to utf8 in MAC, mysqlutf8

1. Check the character set of the default installed mysql

Mysql> show variables like '% char % ';
+ -------------------------- + -------------------------------------------------------- +
| Variable_name | Value |
+ -------------------------- + -------------------------------------------------------- +
| Character_set_client | utf8 |
| Character_set_connection | utf8 |
| Character_set_database | latin1 |
| Character_set_filesystem | binary |
| Character_set_results | utf8 |
| Character_set_server | latin1 |
| Character_set_system | utf8 |
| Character_sets_dir |/usr/local/mysql-5.5.23-osx10.6-x86_64/share/charsets/|
+ -------------------------- + -------------------------------------------------------- +
8 rows in set (0.00 sec)

Character_set_database and character_set_server are still latin1 character sets. That is to say, the tables created in mysql are latin1 character sets instead of utf8, which may cause some trouble. Therefore, it is necessary to modify my. cnf and shut down the mysql process before modifying my. cnf. Otherwise, the mysql sock cannot be connected.

2. Disable the mysqld background process.

Control mysqld in the system preference settings to avoid the trouble of finding the installation location of mysqld.

Click Stop MySQL Server

3. Modify the mysql configuration file/etc/my. cnf.

Sudo cp/usr/local/mysql/support-files/my-medium.cnf/etc/my. cnf

Sudo vi/etc/my. cnf

Add the [client] section:

Default-character-set = utf8

The [mysqld] section is added as follows:

Character-set-server = utf8

Start mysql after modification.

4. check results:

Mysql> show variables like '% char % ';
+ -------------------------- + -------------------------------------------------------- +
| 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/local/mysql-5.5.23-osx10.6-x86_64/share/charsets/|
+ -------------------------- + -------------------------------------------------------- +
8 rows in set (0.00 sec)

Modified #

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.