From 4bff688a88727908f0ddb2469609e87d1583d538 Mon Sep 17 00:00:00 2001 From: wuchangqian <30889515@qq.com> Date: Wed, 6 Sep 2017 18:10:41 +0800 Subject: [PATCH] Site updated at 2017-09-06 10:10:41 UTC --- about-me/index.html | 10 +- atom.xml | 115 +------ .../01/17/understand-mysql-charset/index.html | 8 +- blog/2012/03/02/note-of-yum/index.html | 8 +- .../23/command-line-skill-of-linux/index.html | 8 +- blog/2012/05/30/intr-rsa/index.html | 8 +- .../2012/10/19/it-gangwei-shuoming/index.html | 8 +- blog/2012/12/06/use-of-stack/index.html | 8 +- .../08/30/jquery-extend-method/index.html | 8 +- blog/2014/01/31/consistent-hashing/index.html | 8 +- .../index.html | 8 +- .../31/apache-http-request-process/index.html | 8 +- blog/2014/08/31/html-doctype/index.html | 8 +- .../08/31/linux-useful-command/index.html | 8 +- blog/2014/08/31/php-break-keywork/index.html | 8 +- blog/2014/09/01/sed-man-page/index.html | 10 +- blog/2014/10/19/css-clearfix/index.html | 8 +- .../19/mysql-shell-prompt-metachar/index.html | 8 +- blog/2014/10/19/wangzhan-paizhao/index.html | 8 +- blog/2015/01/06/htop/index.html | 8 +- .../07/windows-xia-ffmpegshi-yong/index.html | 8 +- blog/2017/08/10/shell-history/index.html | 10 +- blog/2017/09/06/test/index.html | 239 ++++++++++++++ blog/archives/index.html | 23 +- .../%E5%A4%9A%E5%AA%92%E4%BD%93/atom.xml | 2 +- .../%E5%A4%9A%E5%AA%92%E4%BD%93/index.html | 8 +- blog/categories/%E7%9B%B4%E6%92%AD/atom.xml | 2 +- blog/categories/%E7%9B%B4%E6%92%AD/index.html | 8 +- blog/categories/algorithm/atom.xml | 2 +- blog/categories/algorithm/index.html | 8 +- blog/categories/apache/atom.xml | 2 +- blog/categories/apache/index.html | 8 +- blog/categories/command/atom.xml | 2 +- blog/categories/command/index.html | 8 +- blog/categories/computer/atom.xml | 2 +- blog/categories/computer/index.html | 8 +- blog/categories/css/atom.xml | 2 +- blog/categories/css/index.html | 8 +- blog/categories/doctype/atom.xml | 2 +- blog/categories/doctype/index.html | 8 +- blog/categories/ffmpeg/atom.xml | 2 +- blog/categories/ffmpeg/index.html | 8 +- blog/categories/function/atom.xml | 2 +- blog/categories/function/index.html | 8 +- blog/categories/history/atom.xml | 2 +- blog/categories/history/index.html | 8 +- blog/categories/html/atom.xml | 2 +- blog/categories/html/index.html | 8 +- blog/categories/http/atom.xml | 2 +- blog/categories/http/index.html | 8 +- blog/categories/it/atom.xml | 2 +- blog/categories/it/index.html | 8 +- blog/categories/javascript/atom.xml | 2 +- blog/categories/javascript/index.html | 8 +- blog/categories/jekyll/atom.xml | 2 +- blog/categories/jekyll/index.html | 8 +- blog/categories/jquery/atom.xml | 2 +- blog/categories/jquery/index.html | 8 +- blog/categories/linux/atom.xml | 4 +- blog/categories/linux/index.html | 8 +- blog/categories/mysql/atom.xml | 2 +- blog/categories/mysql/index.html | 8 +- blog/categories/octopress/atom.xml | 2 +- blog/categories/octopress/index.html | 8 +- blog/categories/php/atom.xml | 2 +- blog/categories/php/index.html | 8 +- blog/categories/rsa/atom.xml | 2 +- blog/categories/rsa/index.html | 8 +- blog/categories/sed/atom.xml | 4 +- blog/categories/sed/index.html | 8 +- blog/categories/shell/atom.xml | 4 +- blog/categories/shell/index.html | 8 +- blog/categories/web/atom.xml | 2 +- blog/categories/web/index.html | 8 +- index.html | 91 ++--- posts/2/index.html | 181 +++------- posts/3/index.html | 310 ++++++++++++++++++ sitemap.xml | 4 + 78 files changed, 885 insertions(+), 508 deletions(-) create mode 100644 blog/2017/09/06/test/index.html create mode 100644 posts/3/index.html diff --git a/about-me/index.html b/about-me/index.html index f6e9f93..bcf11ed 100644 --- a/about-me/index.html +++ b/about-me/index.html @@ -9,7 +9,7 @@ Me - 每个人的声音都面向世界 - + @@ -105,6 +105,10 @@

Me

Recent Posts

diff --git a/atom.xml b/atom.xml index 29ffbcd..316a915 100644 --- a/atom.xml +++ b/atom.xml @@ -4,7 +4,7 @@ <![CDATA[每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ @@ -13,6 +13,15 @@ Octopress + + <![CDATA[Test]]> + + 2017-09-06T18:09:15+08:00 + http://me.94313.net/blog/2017/09/06/test + adska

+]]>
+
+ <![CDATA[Shell History 命令扩展]]> @@ -765,7 +774,7 @@ make && make install regular expression matches the newline character, and similarly for \a, \t, and other sequences.

BUGS - E-mail bug reports to bug-sed@gnu.org. Also, please include the output of “sed –version” in the body of your + E-mail bug reports to bug-sed@gnu.org. Also, please include the output of “sed –version” in the body of your report if at all possible.

AUTHOR @@ -2276,108 +2285,6 @@ rpm -ql yum-cron OR # yum update httpd -y –downloadonly –downloaddir=/opt ##下载到指定目录 # yum install perl-MailTools –downloadonly –downloaddir=/opt -y ##如果软件已经下载过了,必须使用这个来下载

-]]> -
- - - <![CDATA[理解Mysql字符集设置]]> - - 2012-01-17T10:39:27+08:00 - http://me.94313.net/blog/2012/01/17/understand-mysql-charset - 基本概念 - -
    -
  • 字符(Character)是指人类语言中最小的表义符号。例如’A’、’B’等;
  • -
  • 给定一系列字符,对每个字符赋予一个数值,用数值来代表对应的字符,这一数值就是字符的编码(Encoding)例如,我们给字符’A’赋予数值0,给字符’B’赋予数值1,则0就是字符’A’的编码;
  • -
  • 给定一系列字符并赋予对应的编码后,所有这些字符和编码对组成的集合就是字符集(Character Set)。例如,给定字符列表为{’A’,’B’}时,{’A’=>0, ‘B’=>1}就是一个字符集;
  • -
  • 字符序(Collation)是指在同一字符集内字符之间的比较规则;
  • -
  • 确定字符序后,才能在一个字符集上定义什么是等价的字符,以及字符之间的大小关系;
  • -
  • 每个字符序唯一对应一种字符集,但一个字符集可以对应多种字符序,其中有一个是默认字符序(Default Collation);
  • -
  • MySQL中的字符序名称遵从命名惯例:以字符序对应的字符集名称开头;以ci(表示大小写不敏感)、cs(表示大小写敏感)或_bin(表示按编码值比较)结尾。例如:在字符序“utf8_general_ci”下,字符“a”和“A”是等价的;
  • -
- - -

MySQL字符集设置

- -

• 系统变量: - – character_set_server:默认的内部操作字符集 - – character_set_client:客户端来源数据使用的字符集 - – character_set_connection:连接层字符集 - – character_set_results:查询结果字符集 - – character_set_database:当前选中数据库的默认字符集 - – character_set_system:系统元数据(字段名等)字符集 - – 还有以collation开头的同上面对应的变量,用来描述字符序。 -• 用introducer指定文本字符串的字符集: - – 格式为:[charset] ’string’ [COLLATE collation] - – 例如: - • SELECT latin1 ’string’; - • SELECT utf8 ‘你好’ COLLATE utf8_general_ci; - – 由introducer修饰的文本字符串在请求过程中不经过多余的转码,直接转换为内部字符集处理。

- -

MySQL中的字符集转换过程

- -
1. MySQL Server收到请求时将请求数据从character_set_client转换为character_set_connection;
-2. 进行内部操作前将请求数据从character_set_connection转换为内部操作字符集,其确定方法如下:
-    • 使用每个数据字段的CHARACTER SET设定值;
-    • 若上述值不存在,则使用对应数据表的DEFAULT CHARACTER SET设定值(MySQL扩展,非SQL标准);
-    • 若上述值不存在,则使用对应数据库的DEFAULT CHARACTER SET设定值;
-    • 若上述值不存在,则使用character_set_server设定值。
-3. 将操作结果从内部操作字符集转换为character_set_results。
-
- -

understand-mysql-charset

- -

常见问题解析

- -
    -
  • 向默认字符集为utf8的数据表插入utf8编码的数据前没有设置连接字符集,查询时设置连接字符集为utf8
  • -
  • 插入时根据MySQL服务器的默认设置,character_set_client、character_set_connection和character_set_results均为latin1;
  • -
  • 插入操作的数据将经过latin1=>latin1=>utf8的字符集转换过程,这一过程中每个插入的汉字都会从原始的3个字节变成6个字节保存;
  • -
  • 查询时的结果将经过utf8=>utf8的字符集转换过程,将保存的6个字节原封不动返回,产生乱码……
  • -
- - -

understand-mysql-charset

- -
    -
  • 向默认字符集为latin1的数据表插入utf8编码的数据前设置了连接字符集为utf8
  • -
  • 插入时根据连接字符集设置,character_set_client、character_set_connection和character_set_results均为utf8;
  • -
  • 插入数据将经过utf8=>utf8=>latin1的字符集转换,若原始数据中含有\u0000~\u00ff范围以外的Unicode字 符,会因为无法在latin1字符集中表示而被转换为“?”(0×3F)符号,以后查询时不管连接字符集设置如何都无法恢复其内容了。
  • -
- - -

understand-mysql-charset

- -

检测字符集问题的一些手段

- -
    -
  • SHOW CHARACTER SET;
  • -
  • SHOW COLLATION;
  • -
  • SHOW VARIABLES LIKE ‘character%’;
  • -
  • SHOW VARIABLES LIKE ‘collation%’;
  • -
  • SQL函数HEX、LENGTH、CHAR_LENGTH
  • -
  • SQL函数CHARSET、COLLATION
  • -
- - -

使用MySQL字符集时的建议

- -
    -
  • 建立数据库/表和进行数据库操作时尽量显式指出使用的字符集,而不是依赖于MySQL的默认设置,否则MySQL升级时可能带来很大困扰;
  • -
  • 数据库和连接字符集都使用latin1时虽然大部分情况下都可以解决乱码问题,但缺点是无法以字符为单位来进行SQL操作,一般情况下将数据库和连接字符集都置为utf8是较好的选择;
  • -
  • 使用mysql C API时,初始化数据库句柄后马上用mysql_options设定MYSQL_SET_CHARSET_NAME属性为utf8,这样就不用显式地用 SET NAMES语句指定连接字符集,且用mysql_ping重连断开的长连接时也会把连接字符集重置为utf8;
  • -
  • 对于mysql PHP API,一般页面级的PHP程序总运行时间较短,在连接到数据库以后显式用SET NAMES语句设置一次连接字符集即可;但当使用长连接时,请注意保持连接通畅并在断开重连后用SET NAMES语句显式重置连接字符集。
  • -
- - -

其他注意事项

- -
    -
  • my.cnf中的default_character_set设置只影响mysql命令连接服务器时的连接字符集,不会对使用libmysqlclient库的应用程序产生任何作用!
  • -
  • 对字段进行的SQL函数操作通常都是以内部操作字符集进行的,不受连接字符集设置的影响。
  • -
  • SQL语句中的裸字符串会受到连接字符集或introducer设置的影响,对于比较之类的操作可能产生完全不同的结果,需要小心!
  • -
- ]]>
diff --git a/blog/2012/01/17/understand-mysql-charset/index.html b/blog/2012/01/17/understand-mysql-charset/index.html index 34ea520..17cc0e7 100644 --- a/blog/2012/01/17/understand-mysql-charset/index.html +++ b/blog/2012/01/17/understand-mysql-charset/index.html @@ -223,6 +223,10 @@

其他注意事项

Recent Posts

diff --git a/blog/2012/03/02/note-of-yum/index.html b/blog/2012/03/02/note-of-yum/index.html index 47eec14..9a43dcc 100644 --- a/blog/2012/03/02/note-of-yum/index.html +++ b/blog/2012/03/02/note-of-yum/index.html @@ -339,6 +339,10 @@

附:

Recent Posts

diff --git a/blog/2012/03/23/command-line-skill-of-linux/index.html b/blog/2012/03/23/command-line-skill-of-linux/index.html index a9c5914..295eb69 100644 --- a/blog/2012/03/23/command-line-skill-of-linux/index.html +++ b/blog/2012/03/23/command-line-skill-of-linux/index.html @@ -198,6 +198,10 @@

注意:

Recent Posts

diff --git a/blog/2012/05/30/intr-rsa/index.html b/blog/2012/05/30/intr-rsa/index.html index 0234f19..e1ca8b3 100644 --- a/blog/2012/05/30/intr-rsa/index.html +++ b/blog/2012/05/30/intr-rsa/index.html @@ -158,6 +158,10 @@

RSA加密算法简单介绍

Recent Posts

diff --git a/blog/2012/10/19/it-gangwei-shuoming/index.html b/blog/2012/10/19/it-gangwei-shuoming/index.html index 95d3fb6..d7b779c 100644 --- a/blog/2012/10/19/it-gangwei-shuoming/index.html +++ b/blog/2012/10/19/it-gangwei-shuoming/index.html @@ -342,6 +342,10 @@

岗位:产品经理(当所开发的项目为产品型项目时设立,

Recent Posts

diff --git a/blog/2012/12/06/use-of-stack/index.html b/blog/2012/12/06/use-of-stack/index.html index 479b3b8..06e0801 100644 --- a/blog/2012/12/06/use-of-stack/index.html +++ b/blog/2012/12/06/use-of-stack/index.html @@ -696,6 +696,10 @@

使用栈来找路径

Recent Posts

diff --git a/blog/2013/08/30/jquery-extend-method/index.html b/blog/2013/08/30/jquery-extend-method/index.html index 431b775..b339b9e 100644 --- a/blog/2013/08/30/jquery-extend-method/index.html +++ b/blog/2013/08/30/jquery-extend-method/index.html @@ -229,6 +229,10 @@

jQuery.extend()函数注释说明

Recent Posts

diff --git a/blog/2014/01/31/consistent-hashing/index.html b/blog/2014/01/31/consistent-hashing/index.html index 9a03d5d..7064215 100644 --- a/blog/2014/01/31/consistent-hashing/index.html +++ b/blog/2014/01/31/consistent-hashing/index.html @@ -186,6 +186,10 @@

一致性哈希算法浅析

Recent Posts

diff --git a/blog/2014/05/20/octopress-add-category2rightaside/index.html b/blog/2014/05/20/octopress-add-category2rightaside/index.html index 1ffb90b..28c868e 100644 --- a/blog/2014/05/20/octopress-add-category2rightaside/index.html +++ b/blog/2014/05/20/octopress-add-category2rightaside/index.html @@ -170,6 +170,10 @@

配置侧边栏需要修改_config.yml文件,修改其default_asides项:

Recent Posts

diff --git a/blog/2014/08/31/apache-http-request-process/index.html b/blog/2014/08/31/apache-http-request-process/index.html index 5e5ae63..5e29b37 100644 --- a/blog/2014/08/31/apache-http-request-process/index.html +++ b/blog/2014/08/31/apache-http-request-process/index.html @@ -147,6 +147,10 @@

Apache处理http请求的生命周期

Recent Posts

diff --git a/blog/2014/08/31/html-doctype/index.html b/blog/2014/08/31/html-doctype/index.html index 3869944..a1f31b9 100644 --- a/blog/2014/08/31/html-doctype/index.html +++ b/blog/2014/08/31/html-doctype/index.html @@ -198,6 +198,10 @@

XHTML 1.1

Recent Posts

diff --git a/blog/2014/08/31/linux-useful-command/index.html b/blog/2014/08/31/linux-useful-command/index.html index e876cd2..c412a36 100644 --- a/blog/2014/08/31/linux-useful-command/index.html +++ b/blog/2014/08/31/linux-useful-command/index.html @@ -202,6 +202,10 @@

continue in original dir

Recent Posts

diff --git a/blog/2014/08/31/php-break-keywork/index.html b/blog/2014/08/31/php-break-keywork/index.html index c6f3c51..364ad0f 100644 --- a/blog/2014/08/31/php-break-keywork/index.html +++ b/blog/2014/08/31/php-break-keywork/index.html @@ -161,6 +161,10 @@

PHP Break 关键字

Recent Posts

diff --git a/blog/2014/09/01/sed-man-page/index.html b/blog/2014/09/01/sed-man-page/index.html index 812c9a0..909185c 100644 --- a/blog/2014/09/01/sed-man-page/index.html +++ b/blog/2014/09/01/sed-man-page/index.html @@ -302,7 +302,7 @@

Sed-man-page

regular expression matches the newline character, and similarly for \a, \t, and other sequences.

BUGS - E-mail bug reports to bug-sed@gnu.org. Also, please include the output of “sed –version” in the body of your + E-mail bug reports to bug-sed@gnu.org. Also, please include the output of “sed –version” in the body of your report if at all possible.

AUTHOR @@ -382,6 +382,10 @@

Sed-man-page

Recent Posts

diff --git a/blog/2014/10/19/css-clearfix/index.html b/blog/2014/10/19/css-clearfix/index.html index 7d28b2e..db94e61 100644 --- a/blog/2014/10/19/css-clearfix/index.html +++ b/blog/2014/10/19/css-clearfix/index.html @@ -158,6 +158,10 @@

说明:

Recent Posts

diff --git a/blog/2014/10/19/mysql-shell-prompt-metachar/index.html b/blog/2014/10/19/mysql-shell-prompt-metachar/index.html index 50f8218..32d6b7e 100644 --- a/blog/2014/10/19/mysql-shell-prompt-metachar/index.html +++ b/blog/2014/10/19/mysql-shell-prompt-metachar/index.html @@ -163,6 +163,10 @@

MySQL 的 Prompt 转义字符

Recent Posts

diff --git a/blog/2014/10/19/wangzhan-paizhao/index.html b/blog/2014/10/19/wangzhan-paizhao/index.html index 4ea6a5a..509e1e7 100644 --- a/blog/2014/10/19/wangzhan-paizhao/index.html +++ b/blog/2014/10/19/wangzhan-paizhao/index.html @@ -146,6 +146,10 @@

经营一个网站需要哪些牌照资质

Recent Posts

diff --git a/blog/2015/01/06/htop/index.html b/blog/2015/01/06/htop/index.html index d9b3bdd..7b87162 100644 --- a/blog/2015/01/06/htop/index.html +++ b/blog/2015/01/06/htop/index.html @@ -150,6 +150,10 @@

示例图片

Recent Posts

diff --git a/blog/2017/05/07/windows-xia-ffmpegshi-yong/index.html b/blog/2017/05/07/windows-xia-ffmpegshi-yong/index.html index 6d03815..e1f8aa5 100644 --- a/blog/2017/05/07/windows-xia-ffmpegshi-yong/index.html +++ b/blog/2017/05/07/windows-xia-ffmpegshi-yong/index.html @@ -502,6 +502,10 @@

-ss 指从 10s 开始转码,-t 指转换 10s 的视频 -s 指定尺寸

Recent Posts

diff --git a/blog/2017/08/10/shell-history/index.html b/blog/2017/08/10/shell-history/index.html index 73b176a..0727382 100644 --- a/blog/2017/08/10/shell-history/index.html +++ b/blog/2017/08/10/shell-history/index.html @@ -133,6 +133,8 @@

Shell History 命令扩展

« windows 下ffmpeg使用 + test » +

@@ -145,6 +147,10 @@

Shell History 命令扩展

Recent Posts

diff --git a/blog/2017/09/06/test/index.html b/blog/2017/09/06/test/index.html new file mode 100644 index 0000000..9553a2f --- /dev/null +++ b/blog/2017/09/06/test/index.html @@ -0,0 +1,239 @@ + + + + + + + + + Test - 每个人的声音都面向世界 + + + + + + + + + + + + + + + + + + + + +
+

每个人的声音都面向世界

+ +

木受绳则直,金就砺则利,君子博学而日参省乎己,则知明而行无过矣。

+ +
+ +
+ +
+
+
+
+ +
+ +

Test

+ + +

+ + + + + + + +

+ +
+ + +

adska

+
+ + + +
+ +
+ + + + +
+
+ + + + + + + + + + + + + + + diff --git a/blog/archives/index.html b/blog/archives/index.html index 2554621..9a98a5a 100644 --- a/blog/archives/index.html +++ b/blog/archives/index.html @@ -9,9 +9,10 @@ Blog Archive - 每个人的声音都面向世界 - +May 07 2017 posted in …"> @@ -73,6 +74,16 @@

Blog Archive

2017

+
+ +

Test

+ + + +
+ + +

Shell History 命令扩展

@@ -376,6 +387,10 @@

理解Mysql字符集设

Recent Posts

diff --git a/blog/categories/%E5%A4%9A%E5%AA%92%E4%BD%93/atom.xml b/blog/categories/%E5%A4%9A%E5%AA%92%E4%BD%93/atom.xml index 5a1ef05..4c44d7e 100644 --- a/blog/categories/%E5%A4%9A%E5%AA%92%E4%BD%93/atom.xml +++ b/blog/categories/%E5%A4%9A%E5%AA%92%E4%BD%93/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: 多媒体 | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/%E5%A4%9A%E5%AA%92%E4%BD%93/index.html b/blog/categories/%E5%A4%9A%E5%AA%92%E4%BD%93/index.html index 5f0f18b..f14e3fa 100644 --- a/blog/categories/%E5%A4%9A%E5%AA%92%E4%BD%93/index.html +++ b/blog/categories/%E5%A4%9A%E5%AA%92%E4%BD%93/index.html @@ -96,6 +96,10 @@

Windows 下ffmpeg使

Recent Posts

diff --git a/blog/categories/%E7%9B%B4%E6%92%AD/atom.xml b/blog/categories/%E7%9B%B4%E6%92%AD/atom.xml index 3c891cc..263f988 100644 --- a/blog/categories/%E7%9B%B4%E6%92%AD/atom.xml +++ b/blog/categories/%E7%9B%B4%E6%92%AD/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: 直播 | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/%E7%9B%B4%E6%92%AD/index.html b/blog/categories/%E7%9B%B4%E6%92%AD/index.html index da281b3..6c097f6 100644 --- a/blog/categories/%E7%9B%B4%E6%92%AD/index.html +++ b/blog/categories/%E7%9B%B4%E6%92%AD/index.html @@ -96,6 +96,10 @@

Windows 下ffmpeg使

Recent Posts

diff --git a/blog/categories/algorithm/atom.xml b/blog/categories/algorithm/atom.xml index 70ce946..2d98da8 100644 --- a/blog/categories/algorithm/atom.xml +++ b/blog/categories/algorithm/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Algorithm | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/algorithm/index.html b/blog/categories/algorithm/index.html index 115eb43..6b1ec16 100644 --- a/blog/categories/algorithm/index.html +++ b/blog/categories/algorithm/index.html @@ -127,6 +127,10 @@

RSA加密算法简单介绍

Recent Posts

diff --git a/blog/categories/apache/atom.xml b/blog/categories/apache/atom.xml index e4cb28a..1620358 100644 --- a/blog/categories/apache/atom.xml +++ b/blog/categories/apache/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Apache | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/apache/index.html b/blog/categories/apache/index.html index bc3a41f..b2459e8 100644 --- a/blog/categories/apache/index.html +++ b/blog/categories/apache/index.html @@ -96,6 +96,10 @@

Apache处理http请

Recent Posts

diff --git a/blog/categories/command/atom.xml b/blog/categories/command/atom.xml index e530000..46f3f89 100644 --- a/blog/categories/command/atom.xml +++ b/blog/categories/command/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Command | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/command/index.html b/blog/categories/command/index.html index d8ed5f5..61e0988 100644 --- a/blog/categories/command/index.html +++ b/blog/categories/command/index.html @@ -96,6 +96,10 @@

Shell History 命令扩展

Recent Posts
diff --git a/blog/categories/computer/atom.xml b/blog/categories/computer/atom.xml index 9c6749d..d41cec8 100644 --- a/blog/categories/computer/atom.xml +++ b/blog/categories/computer/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Computer | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/computer/index.html b/blog/categories/computer/index.html index 4754bed..24c4cf8 100644 --- a/blog/categories/computer/index.html +++ b/blog/categories/computer/index.html @@ -158,6 +158,10 @@

理解Mysql字符集设

Recent Posts

diff --git a/blog/categories/css/atom.xml b/blog/categories/css/atom.xml index a91b0a2..9bc35eb 100644 --- a/blog/categories/css/atom.xml +++ b/blog/categories/css/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Css | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/css/index.html b/blog/categories/css/index.html index da04c6a..366c30d 100644 --- a/blog/categories/css/index.html +++ b/blog/categories/css/index.html @@ -96,6 +96,10 @@

Css-clearfix

Recent Posts

diff --git a/blog/categories/doctype/atom.xml b/blog/categories/doctype/atom.xml index 603966a..9759f0f 100644 --- a/blog/categories/doctype/atom.xml +++ b/blog/categories/doctype/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Doctype | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/doctype/index.html b/blog/categories/doctype/index.html index 5afe19f..9639106 100644 --- a/blog/categories/doctype/index.html +++ b/blog/categories/doctype/index.html @@ -96,6 +96,10 @@

html-DocType

Recent Posts

diff --git a/blog/categories/ffmpeg/atom.xml b/blog/categories/ffmpeg/atom.xml index 1dbc252..4a756f3 100644 --- a/blog/categories/ffmpeg/atom.xml +++ b/blog/categories/ffmpeg/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Ffmpeg | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/ffmpeg/index.html b/blog/categories/ffmpeg/index.html index 77463ef..a1cf6f7 100644 --- a/blog/categories/ffmpeg/index.html +++ b/blog/categories/ffmpeg/index.html @@ -96,6 +96,10 @@

Windows 下ffmpeg使

Recent Posts

diff --git a/blog/categories/function/atom.xml b/blog/categories/function/atom.xml index d30babe..5709d5c 100644 --- a/blog/categories/function/atom.xml +++ b/blog/categories/function/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Function | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/function/index.html b/blog/categories/function/index.html index 7820ba4..e70aae6 100644 --- a/blog/categories/function/index.html +++ b/blog/categories/function/index.html @@ -96,6 +96,10 @@

jQuery.extend()函数注释

Recent Posts

diff --git a/blog/categories/history/atom.xml b/blog/categories/history/atom.xml index d50577a..6635ae5 100644 --- a/blog/categories/history/atom.xml +++ b/blog/categories/history/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: History | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/history/index.html b/blog/categories/history/index.html index 8f2f9d5..823dedb 100644 --- a/blog/categories/history/index.html +++ b/blog/categories/history/index.html @@ -96,6 +96,10 @@

Shell History 命令扩展

Recent Posts
diff --git a/blog/categories/html/atom.xml b/blog/categories/html/atom.xml index 02bec4a..92c2e40 100644 --- a/blog/categories/html/atom.xml +++ b/blog/categories/html/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Html | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/html/index.html b/blog/categories/html/index.html index b720b23..26d26f8 100644 --- a/blog/categories/html/index.html +++ b/blog/categories/html/index.html @@ -96,6 +96,10 @@

html-DocType

Recent Posts

diff --git a/blog/categories/http/atom.xml b/blog/categories/http/atom.xml index 152577b..9d46a8c 100644 --- a/blog/categories/http/atom.xml +++ b/blog/categories/http/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Http | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/http/index.html b/blog/categories/http/index.html index 9e9162e..7104173 100644 --- a/blog/categories/http/index.html +++ b/blog/categories/http/index.html @@ -96,6 +96,10 @@

Apache处理http请

Recent Posts

diff --git a/blog/categories/it/atom.xml b/blog/categories/it/atom.xml index 4a9d40f..78b9fdf 100644 --- a/blog/categories/it/atom.xml +++ b/blog/categories/it/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: It | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/it/index.html b/blog/categories/it/index.html index 7bb3758..a156937 100644 --- a/blog/categories/it/index.html +++ b/blog/categories/it/index.html @@ -96,6 +96,10 @@

IT 岗位说明书(岗位

Recent Posts

diff --git a/blog/categories/javascript/atom.xml b/blog/categories/javascript/atom.xml index efee9d5..a45f327 100644 --- a/blog/categories/javascript/atom.xml +++ b/blog/categories/javascript/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Javascript | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/javascript/index.html b/blog/categories/javascript/index.html index 6d7331e..de15199 100644 --- a/blog/categories/javascript/index.html +++ b/blog/categories/javascript/index.html @@ -96,6 +96,10 @@

jQuery.extend()函数注释

Recent Posts

diff --git a/blog/categories/jekyll/atom.xml b/blog/categories/jekyll/atom.xml index 06be4af..40d89ee 100644 --- a/blog/categories/jekyll/atom.xml +++ b/blog/categories/jekyll/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Jekyll | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/jekyll/index.html b/blog/categories/jekyll/index.html index 410b959..983f950 100644 --- a/blog/categories/jekyll/index.html +++ b/blog/categories/jekyll/index.html @@ -96,6 +96,10 @@

Octopress添

Recent Posts

diff --git a/blog/categories/jquery/atom.xml b/blog/categories/jquery/atom.xml index ee01d03..52f5759 100644 --- a/blog/categories/jquery/atom.xml +++ b/blog/categories/jquery/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Jquery | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/jquery/index.html b/blog/categories/jquery/index.html index 17648ec..0fbbf7b 100644 --- a/blog/categories/jquery/index.html +++ b/blog/categories/jquery/index.html @@ -96,6 +96,10 @@

jQuery.extend()函数注释

Recent Posts

diff --git a/blog/categories/linux/atom.xml b/blog/categories/linux/atom.xml index bdbe5fe..57f69e9 100644 --- a/blog/categories/linux/atom.xml +++ b/blog/categories/linux/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Linux | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ @@ -671,7 +671,7 @@ make && make install regular expression matches the newline character, and similarly for \a, \t, and other sequences.

BUGS - E-mail bug reports to bug-sed@gnu.org. Also, please include the output of “sed –version” in the body of your + E-mail bug reports to bug-sed@gnu.org. Also, please include the output of “sed –version” in the body of your report if at all possible.

AUTHOR diff --git a/blog/categories/linux/index.html b/blog/categories/linux/index.html index fa6d81a..3f12c33 100644 --- a/blog/categories/linux/index.html +++ b/blog/categories/linux/index.html @@ -189,6 +189,10 @@

Yum配置笔记

Recent Posts

diff --git a/blog/categories/mysql/atom.xml b/blog/categories/mysql/atom.xml index 9ac78a6..dd7cf72 100644 --- a/blog/categories/mysql/atom.xml +++ b/blog/categories/mysql/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Mysql | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/mysql/index.html b/blog/categories/mysql/index.html index 469f5d5..bc2ae4a 100644 --- a/blog/categories/mysql/index.html +++ b/blog/categories/mysql/index.html @@ -113,6 +113,10 @@

理解Mysql字符集设

Recent Posts

diff --git a/blog/categories/octopress/atom.xml b/blog/categories/octopress/atom.xml index f38b2bc..4a1d5d2 100644 --- a/blog/categories/octopress/atom.xml +++ b/blog/categories/octopress/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Octopress | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/octopress/index.html b/blog/categories/octopress/index.html index 700a177..579536a 100644 --- a/blog/categories/octopress/index.html +++ b/blog/categories/octopress/index.html @@ -96,6 +96,10 @@

Octopress添

Recent Posts

diff --git a/blog/categories/php/atom.xml b/blog/categories/php/atom.xml index 9d0f234..9297397 100644 --- a/blog/categories/php/atom.xml +++ b/blog/categories/php/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Php | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/php/index.html b/blog/categories/php/index.html index 17c8a73..3b4be6e 100644 --- a/blog/categories/php/index.html +++ b/blog/categories/php/index.html @@ -96,6 +96,10 @@

PHP Break 关键字

Recent Posts

diff --git a/blog/categories/rsa/atom.xml b/blog/categories/rsa/atom.xml index 51981cb..99f55c1 100644 --- a/blog/categories/rsa/atom.xml +++ b/blog/categories/rsa/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Rsa | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/rsa/index.html b/blog/categories/rsa/index.html index e6fb2e8..7fe779f 100644 --- a/blog/categories/rsa/index.html +++ b/blog/categories/rsa/index.html @@ -96,6 +96,10 @@

RSA加密算法简单介绍

Recent Posts

diff --git a/blog/categories/sed/atom.xml b/blog/categories/sed/atom.xml index 1121074..a7baf02 100644 --- a/blog/categories/sed/atom.xml +++ b/blog/categories/sed/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Sed | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ @@ -243,7 +243,7 @@ regular expression matches the newline character, and similarly for \a, \t, and other sequences.

BUGS - E-mail bug reports to bug-sed@gnu.org. Also, please include the output of “sed –version” in the body of your + E-mail bug reports to bug-sed@gnu.org. Also, please include the output of “sed –version” in the body of your report if at all possible.

AUTHOR diff --git a/blog/categories/sed/index.html b/blog/categories/sed/index.html index 404e975..9596e53 100644 --- a/blog/categories/sed/index.html +++ b/blog/categories/sed/index.html @@ -96,6 +96,10 @@

Sed-man-page

Recent Posts

diff --git a/blog/categories/shell/atom.xml b/blog/categories/shell/atom.xml index 777f6c6..03d5228 100644 --- a/blog/categories/shell/atom.xml +++ b/blog/categories/shell/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Shell | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ @@ -263,7 +263,7 @@ regular expression matches the newline character, and similarly for \a, \t, and other sequences.

BUGS - E-mail bug reports to bug-sed@gnu.org. Also, please include the output of “sed –version” in the body of your + E-mail bug reports to bug-sed@gnu.org. Also, please include the output of “sed –version” in the body of your report if at all possible.

AUTHOR diff --git a/blog/categories/shell/index.html b/blog/categories/shell/index.html index ccf70d2..0df2d49 100644 --- a/blog/categories/shell/index.html +++ b/blog/categories/shell/index.html @@ -158,6 +158,10 @@

Yum配置笔记

Recent Posts

diff --git a/blog/categories/web/atom.xml b/blog/categories/web/atom.xml index 94267f5..17c2ec6 100644 --- a/blog/categories/web/atom.xml +++ b/blog/categories/web/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Web | 每个人的声音都面向世界]]> - 2017-08-10T17:47:35+08:00 + 2017-09-06T18:10:20+08:00 http://me.94313.net/ diff --git a/blog/categories/web/index.html b/blog/categories/web/index.html index 1b4f14c..76e59eb 100644 --- a/blog/categories/web/index.html +++ b/blog/categories/web/index.html @@ -96,6 +96,10 @@

Css-clearfix

Recent Posts

diff --git a/index.html b/index.html index 36a70a8..a700885 100644 --- a/index.html +++ b/index.html @@ -9,12 +9,8 @@ 每个人的声音都面向世界 - + @@ -65,6 +61,35 @@

木受绳则直,金就砺则利,君子博学而日参省乎己,则知 +
+ +
+ +

Test

+ + +

+ + + + + + + +

+ +
+ + +

adska

+
+ + + + +
+ +
@@ -952,7 +977,7 @@

Sed-man-page

BUGS - E-mail bug reports to bug-sed@gnu.org. Also, please include the output of “sed –version” in the body of your + E-mail bug reports to bug-sed@gnu.org. Also, please include the output of “sed –version” in the body of your report if at all possible.

AUTHOR @@ -1175,50 +1200,6 @@

continue in original dir

-
- - -
- -
- -

Apache处理http请求的生命周期

- - -

- - - - - - - -

- -
- - -

Apache请求处理循环的11个阶段都做了哪些事情呢?

- -
    -
  1. Post-Read-Request阶段: 在正常请求处理流程中,这是模块可以插入钩子的第一个阶段。对于那些想很早进入处理请求的模块来说,这个阶段可以被利用。
  2. -
  3. URI Translation阶段 : Apache在本阶段的主要工作:将请求的URL映射到本地文件系统。模块可以在这阶段插入钩子,执行自己的映射逻辑。mod_alias就是利用这个阶段工作的。
  4. -
  5. Header Parsing阶段 : Apache在本阶段的主要工作:检查请求的头部。由于模块可以在请求处理流程的任何一个点上执行检查请求头部的任务,因此这个钩子很少被使用。mod_setenvif就是利用这个阶段工作的。
  6. -
  7. Access Control阶段 : Apache在本阶段的主要工作:根据配置文件检查是否允许访问请求的资源。Apache的标准逻辑实现了允许和拒绝指令。mod_authz_host就是利用这个阶段工作的。
  8. -
  9. Authentication阶段 : Apache在本阶段的主要工作:按照配置文件设定的策略对用户进行认证,并设定用户名区域。模块可以在这阶段插入钩子,实现一个认证方法。
  10. -
  11. Authorization阶段 : Apache在本阶段的主要工作:根据配置文件检查是否允许认证过的用户执行请求的操作。模块可以在这阶段插入钩子,实现一个用户权限管理的方法。
  12. -
  13. MIME Type Checking阶段 : Apache在本阶段的主要工作:根据请求资源的MIME类型的相关规则,判定将要使用的内容处理函数。标准模块mod_negotiation和mod_mime实现了这个钩子。
  14. -
  15. FixUp阶段 : 这是一个通用的阶段,允许模块在内容生成器之前,运行任何必要的处理流程。和Post_Read_Request类似,这是一个能够捕获任何信息的钩子,也是最常使用的钩子。
  16. -
  17. Response阶段 : Apache在本阶段的主要工作:生成返回客户端的内容,负责给客户端发送一个恰当的回复。这个阶段是整个处理流程的核心部分。
  18. -
  19. Logging阶段 : Apache在本阶段的主要工作:在回复已经发送给客户端之后记录事务。模块可能修改或者替换Apache的标准日志记录。
  20. -
  21. CleanUp阶段 : Apache在本阶段的主要工作:清理本次请求事务处理完成之后遗留的环境,比如文件、目录的处理或者Socket的关闭等等,这是Apache一次请求处理的最后一个阶段。
  22. -
- -
- - - -

diff --git a/posts/2/index.html b/posts/2/index.html index ea89ca3..1631b4e 100644 --- a/posts/2/index.html +++ b/posts/2/index.html @@ -9,9 +9,8 @@ 每个人的声音都面向世界 - + @@ -62,6 +61,50 @@

木受绳则直,金就砺则利,君子博学而日参省乎己,则知 +
+ +
+ +

Apache处理http请求的生命周期

+ + +

+ + + + + + + +

+ +
+ + +

Apache请求处理循环的11个阶段都做了哪些事情呢?

+ +
    +
  1. Post-Read-Request阶段: 在正常请求处理流程中,这是模块可以插入钩子的第一个阶段。对于那些想很早进入处理请求的模块来说,这个阶段可以被利用。
  2. +
  3. URI Translation阶段 : Apache在本阶段的主要工作:将请求的URL映射到本地文件系统。模块可以在这阶段插入钩子,执行自己的映射逻辑。mod_alias就是利用这个阶段工作的。
  4. +
  5. Header Parsing阶段 : Apache在本阶段的主要工作:检查请求的头部。由于模块可以在请求处理流程的任何一个点上执行检查请求头部的任务,因此这个钩子很少被使用。mod_setenvif就是利用这个阶段工作的。
  6. +
  7. Access Control阶段 : Apache在本阶段的主要工作:根据配置文件检查是否允许访问请求的资源。Apache的标准逻辑实现了允许和拒绝指令。mod_authz_host就是利用这个阶段工作的。
  8. +
  9. Authentication阶段 : Apache在本阶段的主要工作:按照配置文件设定的策略对用户进行认证,并设定用户名区域。模块可以在这阶段插入钩子,实现一个认证方法。
  10. +
  11. Authorization阶段 : Apache在本阶段的主要工作:根据配置文件检查是否允许认证过的用户执行请求的操作。模块可以在这阶段插入钩子,实现一个用户权限管理的方法。
  12. +
  13. MIME Type Checking阶段 : Apache在本阶段的主要工作:根据请求资源的MIME类型的相关规则,判定将要使用的内容处理函数。标准模块mod_negotiation和mod_mime实现了这个钩子。
  14. +
  15. FixUp阶段 : 这是一个通用的阶段,允许模块在内容生成器之前,运行任何必要的处理流程。和Post_Read_Request类似,这是一个能够捕获任何信息的钩子,也是最常使用的钩子。
  16. +
  17. Response阶段 : Apache在本阶段的主要工作:生成返回客户端的内容,负责给客户端发送一个恰当的回复。这个阶段是整个处理流程的核心部分。
  18. +
  19. Logging阶段 : Apache在本阶段的主要工作:在回复已经发送给客户端之后记录事务。模块可能修改或者替换Apache的标准日志记录。
  20. +
  21. CleanUp阶段 : Apache在本阶段的主要工作:清理本次请求事务处理完成之后遗留的环境,比如文件、目录的处理或者Socket的关闭等等,这是Apache一次请求处理的最后一个阶段。
  22. +
+ +
+ + + + +
+ +
@@ -1548,132 +1591,12 @@

附:

-
- - -
- -
- -

理解Mysql字符集设置

- - -

- - - - - - - -

- -
- - -

基本概念

- -
    -
  • 字符(Character)是指人类语言中最小的表义符号。例如’A’、’B’等;
  • -
  • 给定一系列字符,对每个字符赋予一个数值,用数值来代表对应的字符,这一数值就是字符的编码(Encoding)例如,我们给字符’A’赋予数值0,给字符’B’赋予数值1,则0就是字符’A’的编码;
  • -
  • 给定一系列字符并赋予对应的编码后,所有这些字符和编码对组成的集合就是字符集(Character Set)。例如,给定字符列表为{’A’,’B’}时,{’A’=>0, ‘B’=>1}就是一个字符集;
  • -
  • 字符序(Collation)是指在同一字符集内字符之间的比较规则;
  • -
  • 确定字符序后,才能在一个字符集上定义什么是等价的字符,以及字符之间的大小关系;
  • -
  • 每个字符序唯一对应一种字符集,但一个字符集可以对应多种字符序,其中有一个是默认字符序(Default Collation);
  • -
  • MySQL中的字符序名称遵从命名惯例:以字符序对应的字符集名称开头;以ci(表示大小写不敏感)、cs(表示大小写敏感)或_bin(表示按编码值比较)结尾。例如:在字符序“utf8_general_ci”下,字符“a”和“A”是等价的;
  • -
- - -

MySQL字符集设置

- -

• 系统变量: - – character_set_server:默认的内部操作字符集 - – character_set_client:客户端来源数据使用的字符集 - – character_set_connection:连接层字符集 - – character_set_results:查询结果字符集 - – character_set_database:当前选中数据库的默认字符集 - – character_set_system:系统元数据(字段名等)字符集 - – 还有以collation开头的同上面对应的变量,用来描述字符序。 -• 用introducer指定文本字符串的字符集: - – 格式为:[charset] ’string’ [COLLATE collation] - – 例如: - • SELECT latin1 ’string’; - • SELECT utf8 ‘你好’ COLLATE utf8_general_ci; - – 由introducer修饰的文本字符串在请求过程中不经过多余的转码,直接转换为内部字符集处理。

- -

MySQL中的字符集转换过程

- -
1. MySQL Server收到请求时将请求数据从character_set_client转换为character_set_connection;
-2. 进行内部操作前将请求数据从character_set_connection转换为内部操作字符集,其确定方法如下:
-    • 使用每个数据字段的CHARACTER SET设定值;
-    • 若上述值不存在,则使用对应数据表的DEFAULT CHARACTER SET设定值(MySQL扩展,非SQL标准);
-    • 若上述值不存在,则使用对应数据库的DEFAULT CHARACTER SET设定值;
-    • 若上述值不存在,则使用character_set_server设定值。
-3. 将操作结果从内部操作字符集转换为character_set_results。
-
- -

understand-mysql-charset

- -

常见问题解析

- -
    -
  • 向默认字符集为utf8的数据表插入utf8编码的数据前没有设置连接字符集,查询时设置连接字符集为utf8
  • -
  • 插入时根据MySQL服务器的默认设置,character_set_client、character_set_connection和character_set_results均为latin1;
  • -
  • 插入操作的数据将经过latin1=>latin1=>utf8的字符集转换过程,这一过程中每个插入的汉字都会从原始的3个字节变成6个字节保存;
  • -
  • 查询时的结果将经过utf8=>utf8的字符集转换过程,将保存的6个字节原封不动返回,产生乱码……
  • -
- - -

understand-mysql-charset

- -
    -
  • 向默认字符集为latin1的数据表插入utf8编码的数据前设置了连接字符集为utf8
  • -
  • 插入时根据连接字符集设置,character_set_client、character_set_connection和character_set_results均为utf8;
  • -
  • 插入数据将经过utf8=>utf8=>latin1的字符集转换,若原始数据中含有\u0000~\u00ff范围以外的Unicode字 符,会因为无法在latin1字符集中表示而被转换为“?”(0×3F)符号,以后查询时不管连接字符集设置如何都无法恢复其内容了。
  • -
- - -

understand-mysql-charset

- -

检测字符集问题的一些手段

- -
    -
  • SHOW CHARACTER SET;
  • -
  • SHOW COLLATION;
  • -
  • SHOW VARIABLES LIKE ‘character%’;
  • -
  • SHOW VARIABLES LIKE ‘collation%’;
  • -
  • SQL函数HEX、LENGTH、CHAR_LENGTH
  • -
  • SQL函数CHARSET、COLLATION
  • -
- - -

使用MySQL字符集时的建议

- -
    -
  • 建立数据库/表和进行数据库操作时尽量显式指出使用的字符集,而不是依赖于MySQL的默认设置,否则MySQL升级时可能带来很大困扰;
  • -
  • 数据库和连接字符集都使用latin1时虽然大部分情况下都可以解决乱码问题,但缺点是无法以字符为单位来进行SQL操作,一般情况下将数据库和连接字符集都置为utf8是较好的选择;
  • -
  • 使用mysql C API时,初始化数据库句柄后马上用mysql_options设定MYSQL_SET_CHARSET_NAME属性为utf8,这样就不用显式地用 SET NAMES语句指定连接字符集,且用mysql_ping重连断开的长连接时也会把连接字符集重置为utf8;
  • -
  • 对于mysql PHP API,一般页面级的PHP程序总运行时间较短,在连接到数据库以后显式用SET NAMES语句设置一次连接字符集即可;但当使用长连接时,请注意保持连接通畅并在断开重连后用SET NAMES语句显式重置连接字符集。
  • -
- - -

其他注意事项

- -
    -
  • my.cnf中的default_character_set设置只影响mysql命令连接服务器时的连接字符集,不会对使用libmysqlclient库的应用程序产生任何作用!
  • -
  • 对字段进行的SQL函数操作通常都是以内部操作字符集进行的,不受连接字符集设置的影响。
  • -
  • SQL语句中的裸字符串会受到连接字符集或introducer设置的影响,对于比较之类的操作可能产生完全不同的结果,需要小心!
  • -
- -
- - - -

diff --git a/posts/3/index.html b/posts/3/index.html new file mode 100644 index 0000000..6354182 --- /dev/null +++ b/posts/3/index.html @@ -0,0 +1,310 @@ + + + + + + + + + 每个人的声音都面向世界 + + + + + + + + + + + + + + + + + + + + +
+

每个人的声音都面向世界

+ +

木受绳则直,金就砺则利,君子博学而日参省乎己,则知明而行无过矣。

+ +
+ +
+ +
+
+
+ + + +
+ +
+ +

理解Mysql字符集设置

+ + +

+ + + + + + + +

+ +
+ + +

基本概念

+ +
    +
  • 字符(Character)是指人类语言中最小的表义符号。例如’A’、’B’等;
  • +
  • 给定一系列字符,对每个字符赋予一个数值,用数值来代表对应的字符,这一数值就是字符的编码(Encoding)例如,我们给字符’A’赋予数值0,给字符’B’赋予数值1,则0就是字符’A’的编码;
  • +
  • 给定一系列字符并赋予对应的编码后,所有这些字符和编码对组成的集合就是字符集(Character Set)。例如,给定字符列表为{’A’,’B’}时,{’A’=>0, ‘B’=>1}就是一个字符集;
  • +
  • 字符序(Collation)是指在同一字符集内字符之间的比较规则;
  • +
  • 确定字符序后,才能在一个字符集上定义什么是等价的字符,以及字符之间的大小关系;
  • +
  • 每个字符序唯一对应一种字符集,但一个字符集可以对应多种字符序,其中有一个是默认字符序(Default Collation);
  • +
  • MySQL中的字符序名称遵从命名惯例:以字符序对应的字符集名称开头;以ci(表示大小写不敏感)、cs(表示大小写敏感)或_bin(表示按编码值比较)结尾。例如:在字符序“utf8_general_ci”下,字符“a”和“A”是等价的;
  • +
+ + +

MySQL字符集设置

+ +

• 系统变量: + – character_set_server:默认的内部操作字符集 + – character_set_client:客户端来源数据使用的字符集 + – character_set_connection:连接层字符集 + – character_set_results:查询结果字符集 + – character_set_database:当前选中数据库的默认字符集 + – character_set_system:系统元数据(字段名等)字符集 + – 还有以collation开头的同上面对应的变量,用来描述字符序。 +• 用introducer指定文本字符串的字符集: + – 格式为:[charset] ’string’ [COLLATE collation] + – 例如: + • SELECT latin1 ’string’; + • SELECT utf8 ‘你好’ COLLATE utf8_general_ci; + – 由introducer修饰的文本字符串在请求过程中不经过多余的转码,直接转换为内部字符集处理。

+ +

MySQL中的字符集转换过程

+ +
1. MySQL Server收到请求时将请求数据从character_set_client转换为character_set_connection;
+2. 进行内部操作前将请求数据从character_set_connection转换为内部操作字符集,其确定方法如下:
+    • 使用每个数据字段的CHARACTER SET设定值;
+    • 若上述值不存在,则使用对应数据表的DEFAULT CHARACTER SET设定值(MySQL扩展,非SQL标准);
+    • 若上述值不存在,则使用对应数据库的DEFAULT CHARACTER SET设定值;
+    • 若上述值不存在,则使用character_set_server设定值。
+3. 将操作结果从内部操作字符集转换为character_set_results。
+
+ +

understand-mysql-charset

+ +

常见问题解析

+ +
    +
  • 向默认字符集为utf8的数据表插入utf8编码的数据前没有设置连接字符集,查询时设置连接字符集为utf8
  • +
  • 插入时根据MySQL服务器的默认设置,character_set_client、character_set_connection和character_set_results均为latin1;
  • +
  • 插入操作的数据将经过latin1=>latin1=>utf8的字符集转换过程,这一过程中每个插入的汉字都会从原始的3个字节变成6个字节保存;
  • +
  • 查询时的结果将经过utf8=>utf8的字符集转换过程,将保存的6个字节原封不动返回,产生乱码……
  • +
+ + +

understand-mysql-charset

+ +
    +
  • 向默认字符集为latin1的数据表插入utf8编码的数据前设置了连接字符集为utf8
  • +
  • 插入时根据连接字符集设置,character_set_client、character_set_connection和character_set_results均为utf8;
  • +
  • 插入数据将经过utf8=>utf8=>latin1的字符集转换,若原始数据中含有\u0000~\u00ff范围以外的Unicode字 符,会因为无法在latin1字符集中表示而被转换为“?”(0×3F)符号,以后查询时不管连接字符集设置如何都无法恢复其内容了。
  • +
+ + +

understand-mysql-charset

+ +

检测字符集问题的一些手段

+ +
    +
  • SHOW CHARACTER SET;
  • +
  • SHOW COLLATION;
  • +
  • SHOW VARIABLES LIKE ‘character%’;
  • +
  • SHOW VARIABLES LIKE ‘collation%’;
  • +
  • SQL函数HEX、LENGTH、CHAR_LENGTH
  • +
  • SQL函数CHARSET、COLLATION
  • +
+ + +

使用MySQL字符集时的建议

+ +
    +
  • 建立数据库/表和进行数据库操作时尽量显式指出使用的字符集,而不是依赖于MySQL的默认设置,否则MySQL升级时可能带来很大困扰;
  • +
  • 数据库和连接字符集都使用latin1时虽然大部分情况下都可以解决乱码问题,但缺点是无法以字符为单位来进行SQL操作,一般情况下将数据库和连接字符集都置为utf8是较好的选择;
  • +
  • 使用mysql C API时,初始化数据库句柄后马上用mysql_options设定MYSQL_SET_CHARSET_NAME属性为utf8,这样就不用显式地用 SET NAMES语句指定连接字符集,且用mysql_ping重连断开的长连接时也会把连接字符集重置为utf8;
  • +
  • 对于mysql PHP API,一般页面级的PHP程序总运行时间较短,在连接到数据库以后显式用SET NAMES语句设置一次连接字符集即可;但当使用长连接时,请注意保持连接通畅并在断开重连后用SET NAMES语句显式重置连接字符集。
  • +
+ + +

其他注意事项

+ +
    +
  • my.cnf中的default_character_set设置只影响mysql命令连接服务器时的连接字符集,不会对使用libmysqlclient库的应用程序产生任何作用!
  • +
  • 对字段进行的SQL函数操作通常都是以内部操作字符集进行的,不受连接字符集设置的影响。
  • +
  • SQL语句中的裸字符串会受到连接字符集或introducer设置的影响,对于比较之类的操作可能产生完全不同的结果,需要小心!
  • +
+ +
+ + + + +
+ + +
+ + +
+
+ + + + + + + + + + + + + + + diff --git a/sitemap.xml b/sitemap.xml index b248693..f13ca03 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -1,6 +1,10 @@ +http://me.94313.net/blog/2017/09/06/test/ +2017-09-06T18:09:15+08:00 + + http://me.94313.net/blog/2017/08/10/shell-history/ 2017-08-10T11:35:36+08:00