作者:mobiledu2502920413 | 来源:互联网 | 2014-06-09 00:50
ubuntu修改my.cnf文件导致mysql启动不了的问题最近在虚拟机上配置mysql,由于安装后字符集显示为查询一下showvariableslike'character%';+--------------------------+--------------------------
ubuntu修改my.cnf文件导致mysql启动不了的问题
最近在
虚拟机上配置mysql,由于安装后字符集显示为
查询一下show variables like 'character%';
+--------------------------+----------------------------+
| Variable_name | Value | www.2cto.com
+--------------------------+----------------------------+
| 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/ |
+--------------------------+----------------------------+
先需要全部修改为utf8,根据网上提示修改mysql的启动配置文件 my.cnf
网上基本步骤为:
找到[client] 添加:
default-character-set=utf8 //默认字符集为utf8
www.2cto.com
找到[mysqld] 添加:
//默认字符集为utf8
default-character-set=utf8
init_cOnnect='SET NAMES utf8'
可是我根据这样修改后启动
mysql服务报错,启动不了
在网上试了多种解决办法,都没有解决,
最后找到一个方法,可以解决,如下:
其他的还跟上面一样,只有在[mysqld]下面添加的
default-character-set=utf8
改为
character-set-server = utf8
重新启动mysql,启动成功
再查看编码为: www.2cto.com
+--------------------------+----------------------------+
| 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/ |
+--------------------------+----------------------------+