Maison > base de données > tutoriel mysql > le corps du texte

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

WBOY
Libérer: 2016-06-07 15:52:38
original
1189 Les gens l'ont consulté

------------------------------------------------------ | 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)
编码就顺利改掉了。

 

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal