来看下面的sql语句,查看mysql/ target=_blank class=infotextkey>mysql数据库的当前编码:
mysql> show variables like '%set%';
+--------------------------+------------------------------------+
| variable_name | value |
+--------------------------+------------------------------------+
| auto_increment_offset | 1 |
| 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 | /data/mysql5/share/mysql/charsets/ |
+--------------------------+------------------------------------+
9 rows in set (0.00 sec)
mysql> s
--------------
./mysql ver 14.12 distrib 5.0.22, for pc-linux-gnu (i686) using editline wrapper
connection id: 145
current database:
current user: root@localhost
ssl: not in use
current pager: stdout
using outfile: ''
using delimiter: ;
server version: 5.0.22-log
protocol version: 10
connection: localhost via unix socket
server characterset: latin1
db characterset: latin1
client characterset: latin1
conn. characterset: latin1
unix socket: /tmp/mysql.sock
uptime: 2 days 20 hours 48 min 32 sec
threads: 2 questions: 728 slow queries: 0 opens: 0 flush tables: 2 open tables: 66 queries per second avg: 0.003
--------------
设置mysql数据库编码,最简单方法:
set names utf8;