首先先查詢現況:
mysql> status;
...
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
接著設定:
$ ls -la /etc/mysql/
total 24
drwxr-xr-x 3 root root 4096 Mar 27 08:58 .
drwxr-xr-x 91 root root 4096 Mar 26 22:41 ..
drwxr-xr-x 2 root root 4096 Mar 27 09:03 conf.d
-rw------- 1 root root 333 Mar 25 16:00 debian.cnf
-rwxr-xr-x 1 root root 1220 Jan 22 05:48 debian-start
-rw-r--r-- 1 root root 3638 Mar 27 08:56 my.cnf
$ sudo touch /etc/mysql/conf.d/charset.cnf
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
collation-server=utf8_unicode_ci
$ sudo service mysql restart
再查詢一次:
mysql> status;
...
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
參考資料:
沒有留言:
張貼留言