安裝了個5.5版本的mysql,字符集出現了問題,之前的mysql服務器都是通過在my.cnf配置文件中進行配置便可,可是今兒怎麼著都不行一直報錯:
當時系統中也沒有配置錯誤日志,所以只能是先配置下錯誤日志的位置,看看到底是哪裡出錯了:
[html]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306 www.2cto.com
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
log-error=/var/log/mysql/error.log
lc-messages-dir = /usr/share/mysql
skip-external-locking
default-character-set=utf8
結果查看了錯誤日志才發現是字符集的錯誤:
[html]
[ERROR] /usr/sbin/mysqld: unknown variable 'default-character-set=utf8'
居然不認識,上網上了找了下發現也有人遇到了,說是5.5中mysql不再使用default-character-set這種寫法了。
具體請看:http://dev.mysql.com/doc/refman/5.5/en/server-options.html#option_mysqld_default-character-set
把default-character-set=utf8 改成: character-set-server=utf8就可以了。
[html]
root@chenDBA:/etc/mysql# vim my.cnf
root@chenDBA:/etc/mysql# service mysql start
mysql start/running, process 5904
root@chenDBA:/etc/mysql# mysql -uroot -p
Enter password: www.2cto.com
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.00 sec) OK收工了。
作者 chen861201