Preface
 
    MySQL use character set & collation to organize the different charater.It provides a flexible way in setting individual character set on a database,a table even on a single column of table.Each character set has a series of collations with one default collation.We can generally see the character set in MySQL as the combination of code page & character encoding.
    In the early version of MySQL(eg. version 5.5) ,latin1 is the default character set which does not support Chinese characters.There're some other commonly used character set such as GBK,UTF-8.MySQL 5.7 chooses UTF-8 as default character set nowadays in order to support more characters of different languages.
    Messy code is a general issue about character set.It always occur in our MySQL databases if we do not use character rules appropriately.Worse,it leads to data loss in some cases what is really a big trouble we should avoid.
 
Introduce
 
    MySQL provides a lot of parameters to specify character set in various dimentionality.We should know clearly about the principle and function of each parameter to avert underlying messy code issue.Let's see details about it.
 
Procedure
 
Check the character set supported by MySQL(version 5.7).
 (root@localhost mysql3306.sock)[(none)]>show character 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) //There're 41 results of the supported character set.
//Each character set has a default collation.
//Maxlen is the max bytes of corresponding character set(eg. utf8mb4 supports 4 bytes).
Check character set parameters of current MySQL server.
 (root@localhost mysql3306.sock)[(none)]>show variables like 'character%';
+--------------------------+----------------------------------------------------------------+
| Variable_name | Value |
+--------------------------+----------------------------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql-5.7.-linux-glibc2.-x86_64/share/charsets/ |
+--------------------------+----------------------------------------------------------------+
rows in set (0.00 sec) //character_set_client:It's used by client when connect to servers for requesting data.
//character_set_connection:It's used for those literals not have a character set introducer for conversion.
//character_set_database:It's used by default database.The value of "character_set_server" will be inherited if it is not specified.
//character_set_filesystem:It's used to interpret string literals refer to file names.
//character_set_results:It's used to return query results to the client.
//character_set_server:It's the default character set of server.
//character_set_system:It's used by server for storing identifiers,the value is utf8 forever.
//character_sets_dir:It's the directory where contains the xml files of installed character set.
The relationship of  above character set parameters shows below.

 Check collation parameters of current MySQL server.
 (root@localhost mysql3306.sock)[(none)]>show variables like 'collation%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+
rows in set (0.01 sec) //collation_connection:The collation of connection character set.
//collation_database:The collation of default database.It will inherite the value of "collation_server" if not specified.
//collation_server:The default collation of server.
//"ci" means Case Insensitive.
Case of change character set from utf8 to latin1 with "set names ...;".
 (root@localhost mysql3306.sock)[(none)]>\s
--------------
mysql Ver 14.14 Distrib 5.7., for linux-glibc2. (x86_64) using EditLine wrapper Connection id:
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.-log MySQL Community Server (GPL)
Protocol version:
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /tmp/mysql3306.sock
Uptime: hours min sec Threads: Questions: Slow queries: Opens: Flush tables: Open tables: Queries per second avg: 0.003
-------------- (root@localhost mysql3306.sock)[(none)]>set names latin1;
Query OK, rows affected (0.00 sec) (root@localhost mysql3306.sock)[(none)]>\s
--------------
mysql Ver 14.14 Distrib 5.7., for linux-glibc2. (x86_64) using EditLine wrapper Connection id:
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.-log MySQL Community Server (GPL)
Protocol version:
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: latin1
Conn. characterset: latin1
UNIX socket: /tmp/mysql3306.sock
Uptime: hours min sec Threads: Questions: Slow queries: Opens: Flush tables: Open tables: Queries per second avg: 0.003
-------------- (root@localhost mysql3306.sock)[(none)]>select @@character_set_client;
+------------------------+
| @@character_set_client |
+------------------------+
| latin1 |
+------------------------+
row in set (0.00 sec) (root@localhost mysql3306.sock)[(none)]>select @@character_set_connection;
+----------------------------+
| @@character_set_connection |
+----------------------------+
| latin1 |
+----------------------------+
row in set (0.00 sec) (root@localhost mysql3306.sock)[(none)]>select @@character_set_results;
+-------------------------+
| @@character_set_results |
+-------------------------+
| latin1 |
+-------------------------+
row in set (0.00 sec) (root@localhost mysql3306.sock)[(none)]>show variables like '%collation%';
+----------------------+-------------------+
| Variable_name | Value |
+----------------------+-------------------+
| collation_connection | latin1_swedish_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-------------------+
rows in set (0.00 sec) //The influence of command "set names latin1" to character set is to change "character_set_client","character_set_connection","character_set_results" into latin1.
//The influence of command "set names latin1" to collation is to change "collation_connection" into latin1.
Case of change character set from utf8 to latin1 with "set character set ...;".
 (root@localhost mysql3306.sock)[(none)]>\s
--------------
mysql Ver 14.14 Distrib 5.7., for linux-glibc2. (x86_64) using EditLine wrapper Connection id:
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.-log MySQL Community Server (GPL)
Protocol version:
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: latin1
Conn. characterset: utf8
UNIX socket: /tmp/mysql3306.sock
Uptime: hours min sec Threads: Questions: Slow queries: Opens: Flush tables: Open tables: Queries per second avg: 0.004
-------------- (root@localhost mysql3306.sock)[(none)]>select @@character_set_client;
+------------------------+
| @@character_set_client |
+------------------------+
| latin1 |
+------------------------+
row in set (0.00 sec) (root@localhost mysql3306.sock)[(none)]>select @@character_set_connection;
+----------------------------+
| @@character_set_connection |
+----------------------------+
| utf8 |
+----------------------------+
row in set (0.00 sec) (root@localhost mysql3306.sock)[(none)]>select @@character_set_results;
+-------------------------+
| @@character_set_results |
+-------------------------+
| latin1 |
+-------------------------+
row in set (0.00 sec) (root@localhost mysql3306.sock)[(none)]>show variables like '%collation%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+
rows in set (0.00 sec) //The two variables about "connection" was not altered this time.They were still utf8 relevant.
Case of change character set of server & database from utf8 to latin1.
 (root@localhost mysql3306.sock)[(none)]>\s
--------------
mysql Ver 14.14 Distrib 5.7., for linux-glibc2. (x86_64) using EditLine wrapper Connection id:
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.-log MySQL Community Server (GPL)
Protocol version:
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /tmp/mysql3306.sock
Uptime: hours min sec Threads: Questions: Slow queries: Opens: Flush tables: Open tables: Queries per second avg: 0.005
-------------- (root@localhost mysql3306.sock)[(none)]>set character_set_server=latin1;
Query OK, rows affected (0.00 sec) (root@localhost mysql3306.sock)[(none)]>set character_set_database=latin1;
Query OK, rows affected, warning (0.00 sec) (root@localhost mysql3306.sock)[(none)]>show warnings;
+---------+------+-------------------------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------------------------------------------------------------+
| Warning | | Updating 'character_set_database' is deprecated. It will be made read-only in a future release. |
+---------+------+-------------------------------------------------------------------------------------------------+
row in set (0.00 sec) (root@localhost mysql3306.sock)[(none)]>\s
--------------
mysql Ver 14.14 Distrib 5.7., for linux-glibc2. (x86_64) using EditLine wrapper Connection id:
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.-log MySQL Community Server (GPL)
Protocol version:
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /tmp/mysql3306.sock
Uptime: hours min sec Threads: Questions: Slow queries: Opens: Flush tables: Open tables: Queries per second avg: 0.005
-------------- //It shows that change "character_set_server" online is not supported in future release because of safety concern.
//Change character set of database may bring about risk of data loss if your client program using the supersetwhile database using subset.(eg. client->utf8mb4,database->utf8,will lost emoji data.)
Example of messy code.
 (root@localhost mysql3306.sock)[zlm]>create table test_charset(
-> s1 char() character set latin1 not null,
-> s2 char() char set gbk,
-> s3 varchar() charset utf8,
-> s4 varchar()) character set=utf8mb4 engine=innodb;
Query OK, rows affected (0.01 sec) (root@localhost mysql3306.sock)[zlm]>show create table test_charset;
+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| test_charset | CREATE TABLE `test_charset` (
`s1` char() CHARACTER SET latin1 NOT NULL,
`s2` char() CHARACTER SET gbk DEFAULT NULL,
`s3` varchar() CHARACTER SET utf8 DEFAULT NULL,
`s4` varchar() DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
row in set (0.00 sec) (root@localhost mysql3306.sock)[zlm]>insert into test_charset values('ASCII','国标','万国','表情');
Query OK, row affected (0.00 sec) (root@localhost mysql3306.sock)[zlm]>select * from test_charset;
+-------+--------+--------+--------+
| s1 | s2 | s3 | s4 |
+-------+--------+--------+--------+
| ASCII | 国标 | 万国 | 表情 |
+-------+--------+--------+--------+
row in set (0.00 sec) (root@localhost mysql3306.sock)[zlm]>\s
--------------
mysql Ver 14.14 Distrib 5.7., for linux-glibc2. (x86_64) using EditLine wrapper Connection id:
Current database: zlm
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.-log MySQL Community Server (GPL)
Protocol version:
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /tmp/mysql3306.sock
Uptime: hours min sec Threads: Questions: Slow queries: Opens: Flush tables: Open tables: Queries per second avg: 0.006
-------------- (root@localhost mysql3306.sock)[zlm]>set names latin1;
Query OK, rows affected (0.00 sec) (root@localhost mysql3306.sock)[zlm]>\s
--------------
mysql Ver 14.14 Distrib 5.7., for linux-glibc2. (x86_64) using EditLine wrapper Connection id:
Current database: zlm
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.-log MySQL Community Server (GPL)
Protocol version:
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: latin1
Conn. characterset: latin1
UNIX socket: /tmp/mysql3306.sock
Uptime: hours min sec Threads: Questions: Slow queries: Opens: Flush tables: Open tables: Queries per second avg: 0.008
-------------- (root@localhost mysql3306.sock)[zlm]> (root@localhost mysql3306.sock)[zlm]>select * from test_charset;
+-------+------+------+------+
| s1 | s2 | s3 | s4 |
+-------+------+------+------+
| ASCII | ?? | ?? | ?? |
+-------+------+------+------+
row in set (0.00 sec) (root@localhost mysql3306.sock)[zlm]>set names gbk;
Query OK, rows affected (0.00 sec) (root@localhost mysql3306.sock)[zlm]>\s
--------------
mysql Ver 14.14 Distrib 5.7., for linux-glibc2. (x86_64) using EditLine wrapper Connection id:
Current database: zlm
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.-log MySQL Community Server (GPL)
Protocol version:
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: gbk
Conn. characterset: gbk
UNIX socket: /tmp/mysql3306.sock
Uptime: hours min sec Threads: Questions: Slow queries: Opens: Flush tables: Open tables: Queries per second avg: 0.006
-------------- (root@localhost mysql3306.sock)[zlm]>select * from test_charset;
+-------+------+------+------+
| s1 | s2 | s3 | s4 |
+-------+------+------+------+
| ASCII | ¹螠 | β¹ | ± |
+-------+------+------+------+
row in set (0.00 sec) (root@localhost mysql3306.sock)[zlm]>set names utf8mb4;
Query OK, rows affected (0.00 sec) (root@localhost mysql3306.sock)[zlm]>\s
--------------
mysql Ver 14.14 Distrib 5.7., for linux-glibc2. (x86_64) using EditLine wrapper Connection id:
Current database: zlm
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.-log MySQL Community Server (GPL)
Protocol version:
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8mb4
Conn. characterset: utf8mb4
UNIX socket: /tmp/mysql3306.sock
Uptime: hours min sec Threads: Questions: Slow queries: Opens: Flush tables: Open tables: Queries per second avg: 0.006
-------------- (root@localhost mysql3306.sock)[zlm]>select * from test_charset;
+-------+--------+--------+--------+
| s1 | s2 | s3 | s4 |
+-------+--------+--------+--------+
| ASCII | 国标 | 万国 | 表情 |
+-------+--------+--------+--------+
row in set (0.00 sec) //MySQL support define character set on database,table even on a single column.
//Messy code will occur when "character_set_result" is subset of the value of character set which has been stored only if it turns back to the value equal or bigger than the stored value.
Example of losting data.
 (root@localhost mysql3306.sock)[(none)]>\s
--------------
mysql Ver 14.14 Distrib 5.7., for linux-glibc2. (x86_64) using EditLine wrapper Connection id:
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.-log MySQL Community Server (GPL)
Protocol version:
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /tmp/mysql3306.sock
Uptime: min sec Threads: Questions: Slow queries: Opens: Flush tables: Open tables: Queries per second avg: 0.219
-------------- (root@localhost mysql3306.sock)[(none)]>set @@character_set_server=latin1;
Query OK, rows affected (0.00 sec) (root@localhost mysql3306.sock)[(none)]>set @@character_set_database=latin1;
Query OK, rows affected, warning (0.01 sec) (root@localhost mysql3306.sock)[(none)]>set @@character_set_connection=latin1;
Query OK, rows affected (0.00 sec) (root@localhost mysql3306.sock)[(none)]>\s
--------------
mysql Ver 14.14 Distrib 5.7., for linux-glibc2. (x86_64) using EditLine wrapper Connection id:
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.-log MySQL Community Server (GPL)
Protocol version:
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: latin1
UNIX socket: /tmp/mysql3306.sock
Uptime: min sec Threads: Questions: Slow queries: Opens: Flush tables: Open tables: Queries per second avg: 0.213
-------------- (root@localhost mysql3306.sock)[(none)]>insert into test_charset values('ASCII','国标','万国','表情');
ERROR (3D000): No database selected
(root@localhost mysql3306.sock)[(none)]>use zlm
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
(root@localhost mysql3306.sock)[zlm]>insert into test_charset values('ASCII','国标','万国','表情');
Query OK, row affected, warnings (0.01 sec) (root@localhost mysql3306.sock)[zlm]>show warnings;
+---------+------+-----------------------------------------------------------+
| Level | Code | Message |
+---------+------+-----------------------------------------------------------+
| Warning | | Invalid utf8 character string: '\xE5\x9B\xBD\xE6\xA0\x87' |
| Warning | | Invalid utf8 character string: '\xE4\xB8\x87\xE5\x9B\xBD' |
| Warning | | Invalid utf8 character string: '\xE8\xA1\xA8\xE6\x83\x85' |
+---------+------+-----------------------------------------------------------+
rows in set (0.00 sec) (root@localhost mysql3306.sock)[zlm]>select @@character_set_results;
+-------------------------+
| @@character_set_results |
+-------------------------+
| utf8 |
+-------------------------+
row in set (0.00 sec) (root@localhost mysql3306.sock)[zlm]>select * from test_charset;
+-------+--------+--------+--------+
| s1 | s2 | s3 | s4 |
+-------+--------+--------+--------+
| ASCII | 国标 | 万国 | 表情 |
| ASCII | ?? | ?? | ?? |
+-------+--------+--------+--------+
rows in set (0.00 sec) (root@localhost mysql3306.sock)[zlm]>set @@character_set_results=latin1;
Query OK, rows affected (0.00 sec) (root@localhost mysql3306.sock)[zlm]>select @@character_set_results;
+-------------------------+
| @@character_set_results |
+-------------------------+
| latin1 |
+-------------------------+
row in set (0.00 sec) (root@localhost mysql3306.sock)[zlm]>select * from test_charset;
+-------+------+------+------+
| s1 | s2 | s3 | s4 |
+-------+------+------+------+
| ASCII | ?? | ?? | ?? |
| ASCII | ?? | ?? | ?? |
+-------+------+------+------+
rows in set (0.00 sec) //The data of first row has been correctly resored in database.
//The data of second row has lost the Chinese character data.
//The value of "character_set_result" only influence the screen output.
//There's a data loss risk while value of character set of client is superset of the one of database.
Summary
  • MySQL character set is flexible and various,be more careful when modify data.
  • The parameter "default_character_set" only affect original mysql client not for the other client tools.
  • Make sure your character set of client is a subset but superset of the value of database when modifying data.Meanwhile it needs to be small than character set of connection to avoid data loss.
  • It's recommended to set character set of database to a big set such as utf8 even utf8mb4 to be compatible with most characters of various languages.
 

浅谈MySQL字符集的更多相关文章

  1. 浅谈mysql主从复制的高可用解决方案

    1.熟悉几个组件(部分摘自网络)1.1.drbd     —— DRBD(Distributed Replicated Block Device),DRBD号称是 "网络 RAID" ...

  2. 浅谈mysql innodb缓存策略

    浅谈mysql innodb缓存策略: The InnoDB Buffer Pool Innodb 持有一个存储区域叫做buffer pool是为了在内存中缓存数据和索引,知道innodb buffe ...

  3. 浅谈mysql配置优化和sql语句优化【转】

    做优化,我在这里引用淘宝系统分析师蒋江伟的一句话:只有勇于承担,才能让人有勇气,有承担自己的错误的勇气.有承担错误的勇气,就有去做事得勇气.无论做什么事,只要是对的,就要去做,勇敢去做.出了错误,承担 ...

  4. 浅谈MySQL中优化sql语句查询常用的30种方法 - 转载

    浅谈MySQL中优化sql语句查询常用的30种方法 1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2.应尽量避免在 where 子句中使 ...

  5. 浅谈Mysql共享锁、排他锁、悲观锁、乐观锁及其使用场景

    浅谈Mysql共享锁.排他锁.悲观锁.乐观锁及其使用场景   Mysql共享锁.排他锁.悲观锁.乐观锁及其使用场景 一.相关名词 |--表级锁(锁定整个表) |--页级锁(锁定一页) |--行级锁(锁 ...

  6. 浅谈MySQL存储引擎-InnoDB&MyISAM

    存储引擎在MySQL的逻辑架构中位于第三层,负责MySQL中的数据的存储和提取.MySQL存储引擎有很多,不同的存储引擎保存数据和索引的方式是不同的.每一种存储引擎都有它的优势和劣势,本文只讨论最常见 ...

  7. 重新学习MySQL数据库6:浅谈MySQL的中事务与锁

    『浅入深出』MySQL 中事务的实现 在关系型数据库中,事务的重要性不言而喻,只要对数据库稍有了解的人都知道事务具有 ACID 四个基本属性,而我们不知道的可能就是数据库是如何实现这四个属性的:在这篇 ...

  8. (转)运维角度浅谈MySQL数据库优化

    转自:http://lizhenliang.blog.51cto.com/7876557/1657465 一个成熟的数据库架构并不是一开始设计就具备高可用.高伸缩等特性的,它是随着用户量的增加,基础架 ...

  9. 运维角度浅谈MySQL数据库优化(转)

    一个成熟的数据库架构并不是一开始设计就具备高可用.高伸缩等特性的,它是随着用户量的增加,基础架构才逐渐完善.这篇博文主要谈MySQL数据库发展周期中所面临的问题及优化方案,暂且抛开前端应用不说,大致分 ...

随机推荐

  1. GitKraken使用教程-基础部分(5)

    7. 提交代码 1) 查看文件改动 修改了某个文件后,在程序右侧会出现已修改文件的列表(如图 1‑1),这里以Test.git 为例,修改了19264.h 的文件编码,将其改为utf8.Unstage ...

  2. JAVA ------ 大牛

    李学凯 :http://blog.csdn.net/qq_27093465/article/details/51750535 码农场:http://www.hankcs.com/program/ 徐刘 ...

  3. Homebrew 安装及更新软件

    brew brew install 安装 brew uninstall 卸载 brew update 更新 homebrew brew upgrade 安装已更新软件 brew cleanup 清理 ...

  4. The fool doth think he is wise, but the wise man knows himself to be a fool.

    The fool doth think he is wise, but the wise man knows himself to be a fool.愚者总自以为聪明,智者则有自知之明.

  5. canvas实例(基础)

    JS实现五子棋大战:GitHub源码 知识点总结: 第一步.基础: //获取canvas var chess = document.getElementById('chess'); //获取上下文,创 ...

  6. <Android 基础(十五)> Alert Dialog

    介绍 The AlertDialog class allows you to build a variety of dialog designs and is often the only dialo ...

  7. 一步步理解typedef

    1.如何用C语言实现一个函数,传递两个整形数,返回两个数的和? #include<stdio.h> int add(int a,int b) { return a+b; } void ma ...

  8. 【Android 界面效果49】RecyclerView高度随Item自适应

    编写RecyclerView.ItemDecoration时,在onDraw方法中,Drawable的高度等于RecyclerView的高度减去RecyclerView的上下padding. @Ove ...

  9. Apache Module mod_ssl

    http://httpd.apache.org/docs/current/mod/mod_ssl.html Description: Strong cryptography using the Sec ...

  10. Python基础学习之标识符

    1.合法的Python标识符 Python标识符字符串规则和其他大部分用C编写的高级语言相似: 第一个字符必须是字母或下划线(_) 剩下的字符可以是字母和数字或下滑线 大小写敏感 标识符不能以数字开头 ...