安裝了個5.5版本的mysql,字元集出現了問題,之前的mysql伺服器都是通過在my.cnf設定檔中進行配置便可,可是今兒怎麼著都不行一直報錯:
當時系統中也沒有配置錯誤記錄檔,所以只能是先配置下錯誤記錄檔的位置,看看到底是哪裡出錯了:
複製代碼 代碼如下:user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
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
結果查看了錯誤記錄檔才發現是字元集的錯誤:
複製代碼 代碼如下:[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就可以了。
複製代碼 代碼如下: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:
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收工了。