1.安装mysql
$ sudo apt-get install mysql-server
2.字符集设置
$ sudo vim /etc/mysql/my.cnf
追加如下内容
[client]
default-character-set=utf8 #增加这一行,指定
socket=/var/run/mysqld/mysqld.sock
[mysqld]
character_set_server=utf8 #增加这一行,指定字符集
pid-file=/var/run/mysqld/mysqld.pid
3.验证
$ mysql -u root -p
mysql> SHOW VARIABLES LIKE ‘character_set_%’;
+--------------------------+----------------------------+
| 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/share/mysql/charsets/ |
+--------------------------+----------------------------+