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 #