Find the mysql tutorial configuration file
The mysql configuration file is/etc/init. d/mysql/my. cnf. (This file does not necessarily exist if it is not ubuntu9.0.4. Since the MySQL installation method you may use is different from the one mentioned on the Internet, you may not be able to find/etc/init. d/mysql/my. cnf. Therefore, you need to use the find command to find the cnf file. Remember not to go to my. cnf because it does not necessarily exist, but should look for *. cnf.
2. Back up cp/etc/init. d/mysql/my. cnf/etc/my. cnf. bak before modification.
Open my. cnf and modify the encoding.
# Sudo vi/etc/init. d/mysql/my. cnf
Add under [mysqld]
Default-character-set = utf8
Add under [client]
Default-character-set = utf8
3. Restart mysql
Use unused commands to restart your mysql instance based on the method in which you install mysql. If you have configured the mysqld auto-start mode, you can execute
Cd/usr/bin/
Mysqladmin-uroot-proot shutdownmysqld_safe & (if the permission is insufficient, run sudo mysql_safe &)
4. Use the statement show variables like 'character %'
Only one is latin and the other is utf8.
Change the cmd (dos) encoding method in windows to UTF-8
Chcp command,
Chcp 65001 is replaced with the UTF-8 code page
Chcp 936 can be switched back to the default GBK
Chcp 437 is in the United States. Note: modifying the encoding in personal testing CMD cannot solve MYSQL garbled characters.