查看不同的MySQL字符集有不同的方法,下面介绍的命令用于查看当前支持的MySQL字符集,希望对您学习MySQL字符集能有所帮助。

mysql> show char set;
+----------+---------------------------------+---------------------+--------+
| Charset | Description | Default collation | Maxlen |
+----------+---------------------------------+---------------------+--------+
| big5 | Big5 Traditional Chinese | big5_chinese_ci | |
| dec8 | DEC West European | dec8_swedish_ci | |
| cp850 | DOS West European | cp850_general_ci | |
| hp8 | HP West European | hp8_english_ci | |
| koi8r | KOI8-R Relcom Russian | koi8r_general_ci | |
| latin1 | cp1252 West European | latin1_swedish_ci | |
| latin2 | ISO - Central European | latin2_general_ci | |
| swe7 | 7bit Swedish | swe7_swedish_ci | |
| ascii | US ASCII | ascii_general_ci | |
| ujis | EUC-JP Japanese | ujis_japanese_ci | |
| sjis | Shift-JIS Japanese | sjis_japanese_ci | |
| hebrew | ISO - Hebrew | hebrew_general_ci | |
| tis620 | TIS620 Thai | tis620_thai_ci | |
| euckr | EUC-KR Korean | euckr_korean_ci | |
| koi8u | KOI8-U Ukrainian | koi8u_general_ci | |
| gb2312 | GB2312 Simplified Chinese | gb2312_chinese_ci | |
| greek | ISO - Greek | greek_general_ci | |
| cp1250 | Windows Central European | cp1250_general_ci | |
| gbk | GBK Simplified Chinese | gbk_chinese_ci | |
| latin5 | ISO - Turkish | latin5_turkish_ci | |
| armscii8 | ARMSCII- Armenian | armscii8_general_ci | |
| utf8 | UTF- Unicode | utf8_general_ci | |
| ucs2 | UCS- Unicode | ucs2_general_ci | |
| cp866 | DOS Russian | cp866_general_ci | |
| keybcs2 | DOS Kamenicky Czech-Slovak | keybcs2_general_ci | |
| macce | Mac Central European | macce_general_ci | |
| macroman | Mac West European | macroman_general_ci | |
| cp852 | DOS Central European | cp852_general_ci | |
| latin7 | ISO - Baltic | latin7_general_ci | |
| utf8mb4 | UTF- Unicode | utf8mb4_general_ci | |
| cp1251 | Windows Cyrillic | cp1251_general_ci | |
| utf16 | UTF- Unicode | utf16_general_ci | |
| utf16le | UTF-16LE Unicode | utf16le_general_ci | |
| cp1256 | Windows Arabic | cp1256_general_ci | |
| cp1257 | Windows Baltic | cp1257_general_ci | |
| utf32 | UTF- Unicode | utf32_general_ci | |
| binary | Binary pseudo charset | binary | |
| geostd8 | GEOSTD8 Georgian | geostd8_general_ci | |
| cp932 | SJIS for Windows Japanese | cp932_japanese_ci | |
| eucjpms | UJIS for Windows Japanese | eucjpms_japanese_ci | |
| gb18030 | China National Standard GB18030 | gb18030_chinese_ci | |
+----------+---------------------------------+---------------------+--------+
rows in set (0.00 sec)

查看mysql的编码:

mysql> status
--------------
mysql Ver 14.14 Distrib 5.7.13, for osx10.11 (x86_64) using EditLine wrapper Connection id: 13332
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.13 Homebrew
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /tmp/mysql.sock
Uptime: 23 hours 11 min 16 sec Threads: 4 Questions: 274795 Slow queries: 0 Opens: 330 Flush tables: 1 Open tables: 143 Queries per second avg: 3.291
--------------

修改mysql编码为utf8mb4:

查找mysql配置文件:

huijundeMacBook-Pro:etc huijunzhang$ which mysql
/usr/local/bin/mysql
huijundeMacBook-Pro:bin huijunzhang$ cd /usr/local/bin
huijundeMacBook-Pro:bin huijunzhang$ vim mysql
mysql mysql_embedded mysql_upgrade mysqld_safe mysqlslap
mysql.server mysql_install_db mysqladmin mysqldump mysqltest
mysql_client_test mysql_plugin mysqlbinlog mysqldumpslow mysqltest_embedded
mysql_client_test_embedded mysql_secure_installation mysqlcheck mysqlimport mysqlxtest
mysql_config mysql_ssl_rsa_setup mysqld mysqlpump
mysql_config_editor mysql_tzinfo_to_sql mysqld_multi mysqlshow
huijundeMacBook-Pro:bin huijunzhang$ vim mysql_config

在mysql_config文件中找到了以下内容:

ldata='/usr/local/var/mysql'
execdir='/usr/local/Cellar/mysql/5.7.13/bin'
bindir='/usr/local/Cellar/mysql/5.7.13/bin'

尝试打开/usr/local/Cellar/mysql/5.7.13/bin

huijundeMacBook-Pro:bin huijunzhang$ cd /usr/local/Cellar/mysql/5.7.13
huijundeMacBook-Pro:5.7.13 huijunzhang$ ls
COPYING README homebrew.mxcl.mysql.plist lib scripts support-files
INSTALL_RECEIPT.json bin include mysql-test share
huijundeMacBook-Pro:5.7.13 huijunzhang$ cd support-files/
huijundeMacBook-Pro:support-files huijunzhang$ ls
magic my-default.cnf mysql-log-rotate mysql.server mysqld_multi.server
huijundeMacBook-Pro:support-files huijunzhang$ cp my-default.cnf /etc/my.cnf
huijundeMacBook-Pro:support-files huijunzhang$ vim /etc/my.cnf

/etc/my.cnf添加以下内容:

[client]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake=FALSE
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
[mysql]
default-character-set = utf8mb4

重启mysql:

huijundeMacBook-Pro:etc huijunzhang$ mysql.server restart
Shutting down MySQL
.... SUCCESS!
Starting MySQL
. SUCCESS!

查看mysql的编码

mysql> status
--------------
mysql Ver 14.14 Distrib 5.7.13, for osx10.11 (x86_64) using EditLine wrapper Connection id: 26
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: less
Using outfile: ''
Using delimiter: ;
Server version: 5.7.13 Homebrew
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8mb4
Conn. characterset: utf8mb4
UNIX socket: /tmp/mysql.sock
Uptime: 11 hours 55 min 45 sec Threads: 2 Questions: 72312 Slow queries: 0 Opens: 136 Flush tables: 1 Open tables: 129 Queries per second avg: 1.683
--------------

至此,大功告成

查看当前支持的MySQL字符集的命令的更多相关文章

  1. How can I view currently running MySQL queries?( 查看正在运行的MySQL语句/脚本命令)

    show processlist;show processlist\G;SHOW FULL PROCESSLIST;SHOW FULL PROCESSLIST\G; REF:http://dev.my ...

  2. 查看mysql字符集及修改表结构--表字符集,字段字符集

    MySQL 乱码的根源是的 MySQL 字符集设置不当的问题,本文汇总了有关查看 MySQL 字符集的命令.包括查看 MySQL 数据库服务器字符集.查看 MySQL 数据库字符集,以及数据表和字段的 ...

  3. 查看mysql字符集及修改表结构

    MySQL 乱码的根源是的 MySQL 字符集设置不当的问题,本文汇总了有关查看 MySQL 字符集的命令.包括查看 MySQL 数据库服务器字符集.查看 MySQL 数据库字符集,以及数据表和字段的 ...

  4. 查看三种MySQL字符集的方法

    查看MySQL字符集的命令是我们经常会使用到的,下文就介绍了其中的三种查看MySQL字符集的命令,供您参考学习. 作者:佚名来源:互联网|2010-10-09 11:36 移动端 收藏 分享 CTO训 ...

  5. 如何修改MySQL字符集

    首先,MySQL的字符集问题主要是两个概念,一个是Character Sets,一个是Collations,前者是字符内容及编码,后者是对前者进行比较操作的一些规则.这两个参数集可以在数据库实例.单个 ...

  6. MySQL字符集详解

    Reference:  https://www.cnblogs.com/wcwen1990/p/6917109.html MySQL字符集详解   一.字符集和校验规则 字符集是一套符合和编码,校验规 ...

  7. MySQL字符集及校对规则的理解

      阅读目录:MySQL的字符集和校对规则 MySQL的字符集 MySQL与字符集 正确使用字符集 MySQL客户端与字符集 字符集编码转换原理 字符集常见处理操作 字符集的正确实践 MySQL的校对 ...

  8. mysql数据库中,查看当前支持的字符集有哪些?字符集默认的collation的名字?

    需求描述: mysql数据库支持很多字符集,那么如何查看当前的mysql版本中支持的或者说可用的字符集有什么呢? 操作过程: 1.使用show character set的方式获取当前版本中支持的字符 ...

  9. CentOS 查看和修改 Mysql 字符集

    客户提供了 mysql 的环境,但是不支持中文,通过以下命令查看了 mysql 的字符集 mysql> show variables like 'character_set%'; 显示如下: + ...

随机推荐

  1. Android应用程序窗口(Activity)的绘图表面(Surface)的创建过程分析

    文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/8303098 在前文中,我们分析了应用程序窗口连 ...

  2. 通过匹配绑定select option的文本值 模糊匹配

    //通过匹配绑定select option的文本值 模糊匹配 $(".class option:contains('文本值')").attr("selected" ...

  3. C# DES 加密解密

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.S ...

  4. c++如何生成随机数

    一.使用rand()函数 头文件<stdlib.h> (1)  如果你只要产生随机数而不需要设定范围的话,你只要用rand()就可以了:rand()会返回一随机数值, 范围在0至RAND_ ...

  5. Ubuntu安装中文字体

    Ubuntu没有宋体,楷体之类的中文字体,在Libreoffice中打不出中文,-_-! 我们可以从windows中借点字体过来,哈哈. 一.准备字体 从windows7中拷贝出字体文件,拷贝的目录为 ...

  6. python给多个发送邮件附件,参考于《python自动化运维》

    #!/usr/bin/env python #coding: utf-8 #author:luodi date:2015/02/12 #description:this is a send mail ...

  7. .NET4.0下使用Net2.0类库或程序集

    最近在项目上一直使用.net4.0 framework,使用ffmepeg下的一个dll时,提示只能在2.0下运行,解决方法如下: app.config中添加一个配置节:startup <?xm ...

  8. 恶补ASP.NET基础【1】枚举和结构

    有时我们希望变量提取的是一个固定集合中的值,此时就可以用枚举类型, 例: enum OpenMode : byte { 新增=, 编辑=, 查看= } class Program { static v ...

  9. Nginx 变量漫谈(八)

    与 $arg_XXX 类似,我们在 (二) 中提到过的内建变量 $cookie_XXX 变量也会在名为 XXX 的 cookie 不存在时返回特殊值“没找到”:     location /test  ...

  10. 快速配置 Samba 将 Linux 目录映射为 Windows 驱动器

    原文链接 samba client ubuntu redhat ubuntu gui tools 1,列出某个IP地址所提供的共享文件夹 smbclient -L 198.168.0.1   2,在s ...