当前位置:Gxlcms > mysql > ubuntu12.04修改mysql配置文件my.cnf编码出错---解决方法

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

时间:2021-07-01 10:21:17 帮助过:19人阅读

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

人气教程排行