Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-07 15:52:38
Original
1189 people have browsed it

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

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template