如何查看mysql编码与mysql版本

发布时间:2020-03-11编辑:脚本学堂
本文介绍了查看mysql数据库编码与mysql版本的方法,通过实例学习mysql编码与mysql版本的查看方法,有需要的朋友参考下。

来看下面的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;