Modify the default encoding of MySQL to utf8. Suppose you have followed the Ubuntu installation method (see www. linuxidc. comLinux2012-03)
Modify the default encoding of MySQL to utf8. Suppose you have followed the way to install MySQL under Ubuntu (see http://www.linuxidc.com/Linux/2012-03
Take utf8 as an example. Assume that you have installed MySQL in Ubuntu (SEE) and the installation is successful.
1. Stop mysql
Sudo/etc/init. d/mysql. server stop
2. modify my. cnf
Sudo gedit/etc/my. cnf
Find the corresponding part and add the red part.
[Client]
# Mark add
Default-character-set = utf8
# Omitted
# The MySQL server
[Mysqld]
# Mark add
Character_set_server = utf8
# Mark add
Init_connect = 'set NAMES utf8'
# Omitted
3. Start mysql
Sudo/etc/init. d/mysql. server start
4. Connect to mysql
Mysql-u root-p
5. Check the encoding.
There are many methods, such as three examples (the following three images ).
A. Command Method
B. Assume that after the default encoding is changed, you have created a database named mydb and a table named mytable.
Note: mytable can be created in mydb only after mydb is used.
C. \ s or status;