首頁  >  文章  >  資料庫  >  ubuntu12.04 修改mysql配置文件my.cnf编码出错---解决方法

ubuntu12.04 修改mysql配置文件my.cnf编码出错---解决方法

WBOY
WBOY原創
2016-06-07 15:52:381185瀏覽

------------------------------------------------------ | Variable_name | Value | ------------------------------------------------------ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 |

+--------------------------+----------------------------+
| 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/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

character_set_database和character_set_server的编码还是继承自编译的

直接修改配置文件 my.cnf:[mysqld]下添加default-character-set=utf8

$sudo service mysql restart

mysql stop/waiting
start: Job failed to start
服务竟然起不来

升级ubuntu12.04以后才第一次碰到

最简单的办法是只要在[mysqld]下再加两条配置即可:加上之后如下

default-storage-engine=INNODB 
character-set-server=utf8 
collation-server=utf8_general_ci

$sudo service mysql start
mysql start/running, process 22704

$mysql -u root -p
Enter password:

mysql> show variables like 'character%';
+--------------------------+----------------------------+
| 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/ |
+--------------------------+----------------------------+
8 rows in set (0.01 sec)
编码就顺利改掉了。

 

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn