>: Mysql command line
#mysql -u root -p
password:
>show variables like "character%";
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
>quit
#service mysql stop
#vim /etc/mysql/my.cnf
[client]
default_character_set=utf8
[mysqld]
default_character_set=utf8
init_connect='SET NAMES utf8'
:wq!
#service mysql start
start: Job failed to start
修改my.cnf成
[client]
#default_character_set=utf8 //也就是不要這行
[mysqld]
#deault_character_set=utf8 //也不要這行
character-set-server=utf8
init_connect='SET NAMES utf8'
:wq!
#service mysql start
------------------------------------------------------------------------------
參考文章:
沒有留言:
張貼留言