Modify mysql's default character set to utf8 in mac

Source: Internet
Author: User

Modify the default Character Set of mysql in mac to utf8 1 and check the character set of mysql installed by default.

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 system preference setting to control mysqld, avoiding the trouble of finding the mysqld installation location. 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. cnfsudo vi/etc/my. add the cnf [client] Part: default-character-set = utf8 [mysqld] Part: character-set-server = utf8

 

Exit and save: press ctrl and press the z key twice. Then start mysql 4. Check the result:
Mysql> show variables like '% char % '; + bytes + | Variable_name | Value | + bytes + | character_set_client | utf8 | character_set_connection | utf8 | character_set_database | utf8 | bytes | binary | utf8 | | character_set_server | utf8 | character_set_system | utf8 | character_sets_dir |/usr/local/mysql-5.5.23-osx10.6-x86_64/share/charsets/| + rows + 8 rows in set (0.00 sec) modified #

 


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.