查看不同的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. 具体解释EBS接口开发之物料导入API

    create_item inv_item_grp.create_item(p_commit => fnd_api.g_true, -- p_item_rec => l_item_rec, ...

  2. tomcat使用说明

    tomcat使用说明   1.tomcat的目录结构及说明: 2.发布WEB应用 1).将应用目录达成war包.(将html.jsp.images.WEB-INF目录和当前目录下的所有后缀名为jsp. ...

  3. VisualStudio.DTE 对象可以通过检索 GetService() 方法

    DTE dte = (DTE)GetService(typeof(DTE)); string solutionDir = System.IO.Path.GetDirectoryName(dte.Sol ...

  4. 判断网络是否连接Internet

    添加 system32.Management 引用 private bool ListenNET()        {            ManagementObjectSearcher s = ...

  5. C#调用WebService实例和开发(转)

    1.1.Web Service基本概念 Web Service也叫XML Web Service WebService是一种可以接收从Internet或者Intranet上的其它系统中传递过来的请求, ...

  6. HDU 1065 - I Think I Need a Houseboat

    又是恶心人的水题 圆周率取3.1415926就啥事没有.. #include <iostream> #include <cstdio> #include <cmath&g ...

  7. C++程序设计实践指导1.7超长数列中n个数排序改写要求实现

    改写要求1:将以上程序改写为适合超长整数 改写要求2:将以上程序改写为适合超长数列 改写要求3:将数列中指定位置m开始的n个结点重新按降序排序 改写要求4:输出指定位置m开始的n个结点的超长整数 #i ...

  8. js禁止中文输入 最简洁的【禁止输入中文】

    方法一:禁止中文输入法 <input type="text"  > 方法二:禁止黏贴,禁止拖拽,禁止中文输入法! 这种方法是最强的禁止 中文输入 <input t ...

  9. POJ 1631 Bridging signals & 2533 Longest Ordered Subsequence

    两个都是最长上升子序列,所以就放一起了 1631 因为长度为40000,所以要用O(nlogn)的算法,其实就是另用一个数组c来存储当前最长子序列每一位的最小值,然后二分查找当前值在其中的位置:如果当 ...

  10. Intent、Bundle——实现Activity之间的通信

    http://blog.sina.com.cn/s/blog_62dea93001015847.html 一个应用程序会有多个Activity,但是只有一个Activity作为程序的入口,应用中的其他 ...