tag:blogger.com,1999:blog-49124289129767755372024-03-05T20:12:18.455+08:00另一個MySQL DBA另一個MySQL DBA translate.google.com中國翻譯
||
Another MySQL DBA translated by translate.google.com for ChinaKeith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comBlogger111125tag:blogger.com,1999:blog-4912428912976775537.post-522701849173819912024-02-25T08:43:00.001+08:002024-02-25T08:43:06.314+08:00MariaDB 加密(静态数据)<p><span style="font-family: arial;">下面是一个简单的示例,显示了 MariaDB 加密的几个选项。 </span></p><p><span style="font-family: arial;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">您必须考虑要加密的内容。</span></span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">数据(传输中的数据)或实例中的数据(静态数据)的通信。 </span></span></span></span></span></p><p><span style="font-family: arial;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">本文将重点介绍使用在 Amazon Linux 上运行的 AWS 免费套餐节点的静态数据选项。</span></span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">我将在 2 个不同的实例上使用全局数据库来显示通过加密更新当前表以及将自动加密的新加载表。 </span></span></span></span></span></p><p><span style="font-family: arial;"><br /></span></p><p>
</p><p><span style="font-family: arial;">首先,我们将从安装开始......对于这个演示来说快速而简单。 </span></p><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"> # yum -y install mariadb105-server<br /></span><span style="font-family: courier;"># vi /etc/my.cnf.d/mariadb-server.cnf<br /></span><span style="font-family: courier;"># cat /etc/my.cnf.d/mariadb-server.cnf | grep server_id <br /></span><span style="font-family: courier;">server_id=100</span><span style="font-family: courier;"><br /></span><span style="font-family: courier;"><br /></span><span style="font-family: courier;"># cat /etc/my.cnf.d/mariadb-server.cnf | grep server_id<br /></span><span style="font-family: courier;">server_id=200<br /></span><span style="font-family: courier;"># systemctl start mariadb.service<br /></span><span style="font-family: courier;"># mysql<br /></span><span style="font-family: courier;">MariaDB [(none)]> status<br /></span><span style="font-family: courier;">--------------<br /></span><span style="font-family: courier;">mysql Ver 15.1 Distrib 10.5.23-MariaDB, for Linux (x86_64) using EditLine wrapper</span><span style="font-family: courier;"><br /></span><span style="font-family: courier;">Connection id:<span style="white-space: pre;"> </span>3<br /></span><span style="font-family: courier;">Current database:<br /></span><span style="font-family: courier;">Current user:<span style="white-space: pre;"> </span>root@localhost<br /></span><span style="font-family: courier;">SSL:<span style="white-space: pre;"> </span>Not in use<br /></span><span style="font-family: courier;">Current pager:<span style="white-space: pre;"> </span>stdout<br /></span><span style="font-family: courier;">Using outfile:<span style="white-space: pre;"> </span>''<br /></span><span style="font-family: courier;">Using delimiter:<span style="white-space: pre;"> </span>;<br /></span><span style="font-family: courier;">Server:<span style="white-space: pre;"> </span>MariaDB<br /></span><span style="font-family: courier;">Server version:<span style="white-space: pre;"> </span>10.5.23-MariaDB MariaDB Server<br /></span><span style="font-family: courier;">Protocol version:<span style="white-space: pre;"> </span>10<br /></span><span style="font-family: courier;">Connection:<span style="white-space: pre;"> </span>Localhost via UNIX socket<br /></span><span style="font-family: courier;">Server characterset:<span style="white-space: pre;"> </span>latin1<br /></span><span style="font-family: courier;">Db characterset:<span style="white-space: pre;"> </span>latin1<br /></span><span style="font-family: courier;">Client characterset:<span style="white-space: pre;"> </span>utf8<br /></span><span style="font-family: courier;">Conn. characterset:<span style="white-space: pre;"> </span>utf8<br /></span><span style="font-family: courier;">UNIX socket:<span style="white-space: pre;"> </span>/var/lib/mysql/mysql.sock<br /></span><span style="font-family: courier;">Uptime:<span style="white-space: pre;"> </span>27 sec</span><span style="font-family: courier;"><br /></span><span style="font-family: courier;">MariaDB [(none)]> select @@server_id;<br /></span><span style="font-family: courier;">+-------------+<br /></span><span style="font-family: courier;">| @@server_id |<br /></span><span style="font-family: courier;">+-------------+<br /></span><span style="font-family: courier;">| 100 |<br /></span><span style="font-family: courier;">+-------------+</span><span style="font-family: courier;"><br /></span><span style="font-family: courier;">MariaDB [(none)]> select @@server_id;<br /></span><span style="font-family: courier;">+-------------+<br /></span><span style="font-family: courier;">| @@server_id |<br /></span><span style="font-family: courier;">+-------------+<br /></span><span style="font-family: courier;">| 200 |<br /></span><span style="font-family: courier;">+-------------+</span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><br /></div><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: arial;"><br /></span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: arial;">我们将在实例 server_id 100 上加载全局数据库。 </span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: arial;"><br /></span></p><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"># mysql < world.sql<br /></span><span style="font-family: courier;"># mysql<br /></span><span style="font-family: courier;">Welcome to the MariaDB monitor. Commands end with ; or \g.<br /></span><span style="font-family: courier;">Your MariaDB connection id is 5<br /></span><span style="font-family: courier;">Server version: 10.5.23-MariaDB MariaDB Server</span><span style="font-family: courier;"><br /></span><span style="font-family: courier;">Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.</span><span style="font-family: courier;"><br /></span><span style="font-family: courier;">Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.</span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"><br /></span><span style="font-family: courier;">MariaDB [(none)]> select @@server_id;<br /></span><span style="font-family: courier;">+-------------+<br /></span><span style="font-family: courier;">| @@server_id |<br /></span><span style="font-family: courier;">+-------------+<br /></span><span style="font-family: courier;">| 100 |<br /></span><span style="font-family: courier;">+-------------+<br /></span><span style="font-family: courier;">1 row in set (0.000 sec)</span><span style="font-family: courier;"><br /></span><span style="font-family: courier;">MariaDB [(none)]> show databases;<br /></span><span style="font-family: courier;">+--------------------+<br /></span><span style="font-family: courier;">| Database |<br /></span><span style="font-family: courier;">+--------------------+<br /></span><span style="font-family: courier;">| information_schema |<br /></span><span style="font-family: courier;">| mysql |<br /></span><span style="font-family: courier;">| performance_schema |<br /></span><span style="font-family: courier;">| world |<br /></span><span style="font-family: courier;">+--------------------+<br /></span><span style="font-family: courier;">4 rows in set (0.000 sec)</span><span style="font-family: courier;"><br /></span><span style="font-family: courier;">MariaDB [(none)]> select @@server_id;<br /></span><span style="font-family: courier;">+-------------+<br /></span><span style="font-family: courier;">| @@server_id |<br /></span><span style="font-family: courier;">+-------------+<br /></span><span style="font-family: courier;">| 200 |<br /></span><span style="font-family: courier;">+-------------+<br /></span><span style="font-family: courier;">1 row in set (0.000 sec)</span><span style="font-family: courier;"><br /></span><span style="font-family: courier;">MariaDB [(none)]> show databases;<br /></span><span style="font-family: courier;">+--------------------+<br /></span><span style="font-family: courier;">| Database |<br /></span><span style="font-family: courier;">+--------------------+<br /></span><span style="font-family: courier;">| information_schema |<br /></span><span style="font-family: courier;">| mysql |<br /></span><span style="font-family: courier;">| performance_schema |<br /></span><span style="font-family: courier;">+--------------------+<br /></span><span style="font-family: courier;">3 rows in set (0.000 sec) </span></div><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><br /></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: arial;">现在我们可以看到两个实例当前都没有使用加密。 </span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><br /></p><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">MariaDB [(none)]> select @@server_id;<br />+-------------+<br />| @@server_id |<br />+-------------+<br />| 100 |<br />+-------------+<br />1 row in set (0.000 sec)<br />MariaDB [(none)]> SELECT NAME, ENCRYPTION_SCHEME, CURRENT_KEY_ID FROM information_schema.INNODB_TABLESPACES_ENCRYPTION ;<br />Empty set (0.000 sec)</span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"><br />MariaDB [(none)]> select @@server_id;<br />+-------------+<br />| @@server_id |<br />+-------------+<br />| 200 |<br />+-------------+<br />1 row in set (0.000 sec)<br />MariaDB [(none)]> SELECT NAME, ENCRYPTION_SCHEME, CURRENT_KEY_ID FROM information_schema.INNODB_TABLESPACES_ENCRYPTION ;<br />Empty set (0.000 sec)</span></div><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"><br /></span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: arial;">现在,我将在两个系统上设置随机密钥并对其进行加密。 </span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"># mkdir /etc/mysql/</span></p><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"># mkdir /etc/mysql/encryption/<br /></span><span style="font-family: courier;"># (echo -n "1;" ; openssl rand -hex 32 ) | sudo tee -a /etc/mysql/encryption/keyfile<br /></span><span style="font-family: courier;"># (echo -n "2;" ; openssl rand -hex 32 ) | sudo tee -a /etc/mysql/encryption/keyfile<br /></span><span style="font-family: courier;"># (echo -n "100;" ; openssl rand -hex 32 ) | sudo tee -a /etc/mysql/encryption/keyfile</span><span style="font-family: courier;"><br /></span><span style="font-family: courier;"><br /></span><span style="font-family: courier;"># cat /etc/mysql/encryption/keyfile<br /></span><span style="font-family: courier;">1;466139b487d5735b536a10502b0607d2b96dfa58a7f95ce4847d98ef585af8b5<br /></span><span style="font-family: courier;">2;a0f533c2e459dc64e0aeb1f0f8c9dfb496571e71001ca60fac35c8bbc6361096<br /></span><span style="font-family: courier;">100;4b4bfd61af39d57e068385cf1a023bdfc5972ed414a24167067ca5256fc314e6</span><span style="font-family: courier;"><br /></span><span style="font-family: courier;"><br /></span><span style="font-family: courier;"># cat /etc/mysql/encryption/keyfile<br /></span><span style="font-family: courier;">1;f8b1b250d3bf7159e2abd15be146367415a80d3781bbcf7d96b26640d7efdc8a<br /></span><span style="font-family: courier;">2;c7eaccedd0ef561f0c08d461abfd651947230b08c71aec67c6064bbedb6408ec<br /></span><span style="font-family: courier;">100;90475521b6eb6be3c1ec02770f3e8f80b34130f37d25c89b51cf10ec6a7c5bb6</span><span style="font-family: courier;"><br /></span><span style="font-family: courier;"><br /></span><span style="font-family: courier;">openssl rand -hex 128 > /etc/mysql/encryption/keyfile.key<br /></span><span style="font-family: courier;">openssl enc -aes-256-cbc -md sha1 -pass file:/etc/mysql/encryption/keyfile.key -in /etc/mysql/encryption/keyfile -out /etc/mysql/encryption/keyfile.enc</span><span style="font-family: courier;"><br /></span><span style="font-family: courier;"><br /></span><span style="font-family: courier;"> ls -ltr /etc/mysql/encryption/<br /></span><span style="font-family: courier;">total 12<br /></span><span style="font-family: courier;">-rw-r--r--. 1 root root 203 Feb 24 23:39 keyfile<br /></span><span style="font-family: courier;">-rw-r--r--. 1 root root 257 Feb 24 23:40 keyfile.key<br /></span><span style="font-family: courier;">-rw-r--r--. 1 root root 224 Feb 24 23:41 keyfile.enc</span></div><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"></span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><br /></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: arial;">现在我们可以设置 cnf 文件来启用插件以及加密选项. </span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><br /></p><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"># vi /etc/my.cnf.d/mariadb-server.cnf<br />[mariadb]<br />## File Key Management<br />plugin_load_add = file_key_management<br />loose_file_key_management_filename = /etc/mysql/encryption/keyfile<br />loose_file_key_management_filename = /etc/mysql/encryption/keyfile.enc<br />loose_file_key_management_filekey = FILE:/etc/mysql/encryption/keyfile.key<br />loose_file_key_management_encryption_algorithm = AES_CBC<br /><br /></span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">## InnoDB/XtraDB Encryption Setup<br />innodb_encrypt_log = ON<br />innodb_encrypt_temporary_tables=ON<br />innodb_encryption_threads=4<br />innodb_encrypt_tables=ON<br />innodb_default_encryption_key_id=1<br /><br /></span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">## Aria Encryption Setup<br />aria_encrypt_tables = ON<br /><br />## Temp & Log Encryption<br />encrypt-tmp-disk-tables = 1<br />encrypt-tmp-files = 1<br />encrypt_binlog = ON</span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"><br /></span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><br /></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="background-color: transparent; font-family: arial;">重新启动 MariaDB,以便我们可以检查当前状态. </span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"><br /></span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">systemctl restart mariadb.service</span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">mysql</span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"><div>MariaDB [(none)]> select @@server_id;</div><div>+-------------+</div><div>| @@server_id |</div><div>+-------------+</div><div>| 100 |</div><div>+-------------+</div><div>1 row in set (0.001 sec)</div><div><br /></div><div>MariaDB [(none)]> SELECT NAME, ENCRYPTION_SCHEME, CURRENT_KEY_ID FROM information_schema.INNODB_TABLESPACES_ENCRYPTION ;</div><div>+----------------------------+-------------------+----------------+</div><div>| NAME | ENCRYPTION_SCHEME | CURRENT_KEY_ID |</div><div>+----------------------------+-------------------+----------------+</div><div>| innodb_system | 1 | 1 |</div><div>| mysql/innodb_table_stats | 1 | 1 |</div><div>| mysql/innodb_index_stats | 1 | 1 |</div><div>| mysql/transaction_registry | 1 | 1 |</div><div>| mysql/gtid_slave_pos | 1 | 1 |</div><div>| world/city | 1 | 1 |</div><div>| world/country | 1 | 1 |</div><div>| world/countrylanguage | 1 | 1 |</div><div>+----------------------------+-------------------+----------------+</div><div>8 rows in set (0.000 sec)</div><div><br /></div><div><div>MariaDB [(none)]> select @@server_id;</div><div>+-------------+</div><div>| @@server_id |</div><div>+-------------+</div><div>| 200 |</div><div>+-------------+</div><div>1 row in set (0.000 sec)</div><div><br /></div><div>MariaDB [(none)]> SELECT NAME, ENCRYPTION_SCHEME, CURRENT_KEY_ID FROM information_schema.INNODB_TABLESPACES_ENCRYPTION ;</div><div>+----------------------------+-------------------+----------------+</div><div>| NAME | ENCRYPTION_SCHEME | CURRENT_KEY_ID |</div><div>+----------------------------+-------------------+----------------+</div><div>| innodb_system | 1 | 1 |</div><div>| mysql/innodb_index_stats | 1 | 1 |</div><div>| mysql/gtid_slave_pos | 1 | 1 |</div><div>| mysql/innodb_table_stats | 1 | 1 |</div><div>| mysql/transaction_registry | 1 | 1 |</div><div>+----------------------------+-------------------+----------------+</div><div>5 rows in set (0.000 sec)</div></div></span></div><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><br /></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: arial;">同时将世界数据上传到实例server_id 200。 </span></p><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"># mysql < world.sql<br /># mysql <br />MariaDB [(none)]> select @@server_id;<br />+-------------+<br />| @@server_id |<br />+-------------+<br />| 200 |<br />+-------------+<br />1 row in set (0.000 sec)<br />MariaDB [(none)]> SELECT NAME, ENCRYPTION_SCHEME, CURRENT_KEY_ID FROM information_schema.INNODB_TABLESPACES_ENCRYPTION ;<br />+----------------------------+-------------------+----------------+<br />| NAME | ENCRYPTION_SCHEME | CURRENT_KEY_ID |<br />+----------------------------+-------------------+----------------+<br />| innodb_system | 1 | 1 |<br />| mysql/innodb_index_stats | 1 | 1 |<br />| mysql/gtid_slave_pos | 1 | 1 |<br />| mysql/innodb_table_stats | 1 | 1 |<br />| mysql/transaction_registry | 1 | 1 |<br />| world/city | 1 | 1 |<br />| world/country | 1 | 1 |<br />| world/countrylanguage | 1 | 1 |<br />+----------------------------+-------------------+----------------+<br />8 rows in set (0.000 sec)</span></div><h3 style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; margin: 0px; position: relative;"><br /></h3><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="background-color: transparent; font-family: arial;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">根据 information_schema.INNODB_TABLESPACES_ENCRYPTION 我们现在已加密。</span></span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">但是,它们不会在架构级别显示它。</span></span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">虽然他们说如果它出现在 </span></span></span></span></span><span style="background-color: transparent; font-family: arial;">INNODB_TABLESPACES_ENCRYPTION 表中,它就会被加密,但我更愿意确定并在表和模式中看到它。 </span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier; font-size: 13.2px;"><br /></span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier; font-size: 13.2px;">MariaDB [(none)]> show create table world.city\G</span></p><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">*************************** 1. row ***************************<br /></span><span style="font-family: courier;"> Table: city<br /></span><span style="font-family: courier;">Create Table: CREATE TABLE `city` (<br /></span><span style="font-family: courier;"> `ID` int(11) NOT NULL AUTO_INCREMENT,<br /></span><span style="font-family: courier;"> `Name` char(35) NOT NULL DEFAULT '',<br /></span><span style="font-family: courier;"> `CountryCode` char(3) NOT NULL DEFAULT '',<br /></span><span style="font-family: courier;"> `District` char(20) NOT NULL DEFAULT '',<br /></span><span style="font-family: courier;"> `Population` int(11) NOT NULL DEFAULT 0,<br /></span><span style="font-family: courier;"> PRIMARY KEY (`ID`),<br /></span><span style="font-family: courier;"> KEY `CountryCode` (`CountryCode`),<br /></span><span style="font-family: courier;"> CONSTRAINT `city_ibfk_1` FOREIGN KEY (`CountryCode`) REFERENCES `country` (`Code`)<br /></span><span style="font-family: courier;">) ENGINE=InnoDB AUTO_INCREMENT=4080 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci<br /></span><span style="font-family: courier;">1 row in set (0.001 sec)</span></div><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"><br /></span></p><p><span style="font-family: arial;">到目前为止,您可以看到在 </span><span style="font-family: arial;">重新启动或加载架构和数据后,两个实例都已计入 INNODB_TABLESPACES_ENCRYPTION 架构中。 </span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
</p><p><span style="font-family: arial;">所以...对表格进行一些修改将会有所帮助... </span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><br /></p><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">MariaDB [world]> ALTER TABLE city ENCRYPTED=Yes ENCRYPTION_KEY_ID=1;<br /></span><span style="font-family: courier;">Query OK, 0 rows affected (0.074 sec)<br /></span><span style="font-family: courier;">Records: 0 Duplicates: 0 Warnings: 0</span><span style="font-family: courier;"><br /></span><span style="font-family: courier;">MariaDB [world]> ALTER TABLE country ENCRYPTED=Yes ENCRYPTION_KEY_ID=1;<br /></span><span style="font-family: courier;">Query OK, 0 rows affected (0.031 sec)<br /></span><span style="font-family: courier;">Records: 0 Duplicates: 0 Warnings: 0</span><span style="font-family: courier;"><br /></span><span style="font-family: courier;">MariaDB [world]> ALTER TABLE countrylanguage ENCRYPTED=Yes ENCRYPTION_KEY_ID=1;<br /></span><span style="font-family: courier;">Query OK, 0 rows affected (0.033 sec)<br /></span><span style="font-family: courier;">Records: 0 Duplicates: 0 Warnings: 0</span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"><br /></span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"><div>MariaDB [world]> show create table city\G</div><div>*************************** 1. row ***************************</div><div> Table: city</div><div>Create Table: CREATE TABLE `city` (</div><div> `ID` int(11) NOT NULL AUTO_INCREMENT,</div><div> `Name` char(35) NOT NULL DEFAULT '',</div><div> `CountryCode` char(3) NOT NULL DEFAULT '',</div><div> `District` char(20) NOT NULL DEFAULT '',</div><div> `Population` int(11) NOT NULL DEFAULT 0,</div><div> PRIMARY KEY (`ID`),</div><div> KEY `CountryCode` (`CountryCode`),</div><div> CONSTRAINT `city_ibfk_1` FOREIGN KEY (`CountryCode`) REFERENCES `country` (`Code`)</div><div>) ENGINE=InnoDB AUTO_INCREMENT=4080 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci `ENCRYPTED`=Yes `ENCRYPTION_KEY_ID`=1</div><div>1 row in set (0.000 sec)</div></span></div><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"></span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"><br /></span></p><p><span style="font-family: arial;"><span style="vertical-align: inherit;"><span class="" style="vertical-align: inherit;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">这很简单等等。</span><span style="vertical-align: inherit;">到目前为止...现在我们需要启用二进制日志并检查更多信息。 </span></span></span></span></span></p><p><span style="font-family: arial;"><span style="vertical-align: inherit;"><span class="" style="vertical-align: inherit;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;"><br /></span></span></span></span></span></p><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">vi /etc/my.cnf.d/mariadb-server.cnf<br />log_bin=demo<br /><br /></span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">cat /etc/my.cnf.d/mariadb-server.cnf | grep log_bin<br />log_bin=demo<br /><br /></span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"># systemctl restart mariadb.service<br /><br /></span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">MariaDB [(none)]> select @@server_id;<br />+-------------+<br />| @@server_id |<br />+-------------+<br />| 100 |<br />+-------------+<br />1 row in set (0.000 sec)<br /><br /></span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">MariaDB [(none)]> show master status\G<br />*************************** 1. row ***************************<br /> File: demo.000001<br /> Position: 363<br /> Binlog_Do_DB:<br />Binlog_Ignore_DB:<br /><br /></span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">MariaDB [(none)]> select @@server_id;<br />+-------------+<br />| @@server_id |<br />+-------------+<br />| 200 |<br />+-------------+<br />1 row in set (0.000 sec)<br /><br /></span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">MariaDB [(none)]> show master status\G<br />*************************** 1. row ***************************<br /> File: demo.000001<br /> Position: 363<br /> Binlog_Do_DB:<br />Binlog_Ignore_DB:<br />1 row in set (0.000 sec)</span></div><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"></span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"></span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"></span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"><br /></span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: arial;">通过查看二进制日志来检查...... </span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: arial;"><br /></span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">mariadb-binlog--base64-output=DECODE-ROWS --verbose demo.000001</span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;</span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">/*!40019 SET @@session.max_insert_delayed_threads=0*/;</span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;</span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">DELIMITER /*!*/;</span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"># at 4</span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">#240225 0:06:06 server id 100 end_log_pos 256 CRC32 0x04ce3741 <span style="white-space: pre;"> </span>Start: binlog v 4, server v 10.5.23-MariaDB-log created 240225 0:06:06 at startup</span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"># Warning: this binlog is either in use or was not closed properly.</span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">ROLLBACK/*!*/;</span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"># at 256</span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"># Encryption scheme: 1, key_version: 1, nonce: eb7991b210f3f4d2f7f21537</span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"># The rest of the binlog is encrypted!</span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">ERROR: Error in Log_event::read_log_event(): 'Event decryption failure', data_len: 2400465656, event_type: 240</span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">DELIMITER ;</span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"># End of log file</span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">ROLLBACK /* added by mysqlbinlog */;</span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;</span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"></span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;</span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"><br /></span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: arial;">很高兴看到它说它现在正在加密。 </span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"><br /></span></p><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">MariaDB [world]> create table city2 like city;<br /></span><span style="font-family: courier;">Query OK, 0 rows affected (0.013 sec)</span><span style="font-family: courier;"><br /></span><span style="font-family: courier;"><br /></span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">MariaDB [world]> insert into city2 select * from city;<br /></span><span style="font-family: courier;">Query OK, 4079 rows affected (0.078 sec)<br /></span><span style="font-family: courier;">Records: 4079 Duplicates: 0 Warnings: 0</span><span style="font-family: courier;"><br /></span><span style="font-family: courier;"><br /></span></div><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">MariaDB [world]> show create table city2\G<br /></span><span style="font-family: courier;">*************************** 1. row ***************************<br /></span><span style="font-family: courier;"> Table: city2<br /></span><span style="font-family: courier;">Create Table: CREATE TABLE `city2` (<br /></span><span style="font-family: courier;"> `ID` int(11) NOT NULL AUTO_INCREMENT,<br /></span><span style="font-family: courier;"> `Name` char(35) NOT NULL DEFAULT '',<br /></span><span style="font-family: courier;"> `CountryCode` char(3) NOT NULL DEFAULT '',<br /></span><span style="font-family: courier;"> `District` char(20) NOT NULL DEFAULT '',<br /></span><span style="font-family: courier;"> `Population` int(11) NOT NULL DEFAULT 0,<br /></span><span style="font-family: courier;"> PRIMARY KEY (`ID`),<br /></span><span style="font-family: courier;"> KEY `CountryCode` (`CountryCode`)<br /></span><span style="font-family: courier;">) ENGINE=InnoDB AUTO_INCREMENT=4080 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci `ENCRYPTED`=Yes `ENCRYPTION_KEY_ID`=1<br /></span><span style="font-family: courier;">1 row in set (0.000 sec)</span></div><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"></span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;"><br /></span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: arial;">I want to see these transactions though in the binlog.. how? You can use mariadb_binlog along with --read-from-remote-server to be able to see the data in the logs...</span></p><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><br /></p><div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-family: courier;">mariadb-binlog --base64-output=DECODE-ROWS --verbose --read-from-remote-server demo.000001 | more<br />/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;<br />/*!40019 SET @@session.max_insert_delayed_threads=0*/;<br />/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;<br />DELIMITER /*!*/;<br /># at 4<br />#240225 0:06:06 server id 100 end_log_pos 256 CRC32 0x04ce3741 <span style="white-space: pre;"> </span>Start: binlog v 4, server v 10.5.23-MariaDB-log created 240225 0:06:06 at startup<br />ROLLBACK/*!*/;<br /># at 256<br />#240225 0:06:06 server id 100 end_log_pos 296 CRC32 0x0c89f3bb <span style="white-space: pre;"> </span>Ignorable<br /># Ignorable event type 164 (Start_encryption)<br /># at 296<br />#240225 0:06:06 server id 100 end_log_pos 325 CRC32 0x535776a2 <span style="white-space: pre;"> </span>Gtid list []<br /># at 325<br />#240225 0:06:06 server id 100 end_log_pos 363 CRC32 0x2ac4a61b <span style="white-space: pre;"> </span>Binlog checkpoint demo.000001<br /># at 363<br />#240225 0:09:40 server id 100 end_log_pos 405 CRC32 0x93e10dc4 <span style="white-space: pre;"> </span>GTID 0-100-1 ddl<br />/*!100101 SET @@session.skip_parallel_replication=0*//*!*/;<br />/*!100001 SET @@session.gtid_domain_id=0*//*!*/;<br />/*!100001 SET @@session.server_id=100*//*!*/;<br />/*!100001 SET @@session.gtid_seq_no=1*//*!*/;<br /># at 405<br />#240225 0:09:40 server id 100 end_log_pos 501 CRC32 0x39269040 <span style="white-space: pre;"> </span>Query<span style="white-space: pre;"> </span>thread_id=5<span style="white-space: pre;"> </span>exec_time=0<span style="white-space: pre;"> </span>error_code=0<br />use `world`/*!*/;<br />SET TIMESTAMP=1708819780/*!*/;<br />SET @@session.pseudo_thread_id=5/*!*/;<br />SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_<br />for_timestamp=0/*!*/;<br />SET @@session.sql_mode=1411383296/*!*/;<br />SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;<br />/*!\C utf8 *//*!*/;<br />SET @@session.character_set_client=utf8,@@session.collation_connection=33,@@session.collation_server=8/*!*/;<br />SET @@session.lc_time_names=0/*!*/;<br />SET @@session.collation_database=DEFAULT/*!*/;<br />create table city2 like city<br />/*!*/;<br /># at 501<br />#240225 0:09:49 server id 100 end_log_pos 543 CRC32 0xde82b753 <span style="white-space: pre;"> </span>GTID 0-100-2 trans<br />/*!100001 SET @@session.gtid_seq_no=2*//*!*/;<br />START TRANSACTION<br />/*!*/;<br /># at 543<br /># at 602<br />#240225 0:09:49 server id 100 end_log_pos 602 CRC32 0x05bbb9e6 <span style="white-space: pre;"> </span>Annotate_rows:<br />#Q> insert into city2 select * from city<br />#240225 0:09:49 server id 100 end_log_pos 661 CRC32 0x9e0b4e0d <span style="white-space: pre;"> </span>Table_map: `world`.`city2` mapped to number 21<br /># at 661</span></div><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><br /></p><p><span style="font-family: arial;">希望这至少可以让你开始...... </span></p>
<p><span style="font-family: courier;"><br /></span></p>
<h3><span style="font-family: courier;">资源</span><span style="vertical-align: inherit;">:</span></h3><p style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"><span style="font-size: 13.2px;">https://mariadb.com/kb/en/securing-mariadb-encryption/ </span></p>Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-20743193664886114232020-11-12T23:19:00.002+08:002020-11-12T23:28:49.700+08:00使用您的FRM文件获取Schema,然后导入idb文件。 <p><span style="vertical-align: inherit;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">总的来说,这是一个您永远不必做的主题...为什么?</span></span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">因为您创建的备份是正确的...您已经测试并知道了备份的工作原理,所以您可以仅还原那些备份并获取丢失的架构和相关数据... </span></span></span></span></p><p><span style="vertical-align: inherit;">但是,角落办公室中的一个实例..您从来没有进行设置..那不是那么重要...只是崩溃了,现在您认为了您实际上是如何使用它的... </span></p><p><span style="vertical-align: inherit;">一切都没有丢失。 </span></p><p><span style="vertical-align: inherit;">MySQL不久前发布了他们的MySQL实用程序,之后被MySQL Shell所取代。 </span></p><p></p><ul>
<li><a href="https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://downloads.mysql.com/archives/utilities&usg=ALkJrhjQh_jgcgjK73ElJ6P5_fn9JMOAJQ"><span style="vertical-align: inherit;">https://downloads.mysql.com/archives/utilities</span></a> </li>
<li><a href="https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://dev.mysql.com/downloads/shell/&usg=ALkJrhgFFAxxnOHKKFsLUgO6xrqNb0CdsA"><span style="vertical-align: inherit;">https://dev.mysql.com/downloads/shell/</span></a></li>
</ul><div><span style="vertical-align: inherit;">mysqlfrm仍然非常方便,但是当需要通过快速简单的命令从FRM文件中提取模式时,这是一个简单的安装。 </span></div><div><br /></div><div>
<div class="codebox">
<code>
mysqlfrm --diagnostic city.frm<br />
# WARNING: Cannot generate character set or collation names
without the --server option.
# CAUTION: The diagnostic mode is a best-effort parse of the
.frm file. As such, it may not identify all of the components of the
table correctly. This is especially true for damaged files. It will also
not read the default values for the columns and the resulting statement
may not be syntactically correct.<br />
# Reading .frm file for city.frm:<br />
# The .frm file is a TABLE.<br />
# CREATE TABLE Statement:<br />
<br />
CREATE TABLE `city` (<br />
`ID` int(11) NOT NULL AUTO_INCREMENT,<br />
`Name` char(160) DEFAULT NULL,<br />
`CountryCode` char(12) NOT NULL,<br />
`District` char(80) NOT NULL,<br />
`Population` int(11) NOT NULL,<br />
PRIMARY KEY `PRIMARY` (`ID`),<br />
KEY `CountryCode` (`CountryCode`),<br />
KEY `popkey` (`Population`)<br />
) ENGINE=InnoDB;<br />
<br />
#...done.<br />
</code>
</div>
</div><div><br /></div><div><br /></div><div><span style="vertical-align: inherit;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">因此,现在您拥有丢失的架构...重建数据库或表。</span></span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">对于这个例子的目的,我会说,我们刚刚从世界DB丢失了城市的数据。 </span></span></span></span></div><p></p><div><span style="font-family: monospace;">$ cp </span><span style="font-family: monospace;">city.ibd </span><span style="font-family: monospace;"> / tmp / </span></div><div><span style="font-family: monospace;"><br /></span></div><p>
</p><div>
<div class="codebox">
<code>
$ cp city.ibd /tmp/ <br />
mysql> LOCK TABLES city WRITE;<br />
mysql> ALTER TABLE city DISCARD TABLESPACE;<br />
<br />
cp city.ibd /edb/local/mysql/data/rundeck/<br />
chown tmdba:dba /edb/local/mysql/data/rundeck/city.ibd<br />
<br />
mysql> ALTER TABLE city IMPORT TABLESPACE;<br />
mysql> UNLOCK TABLES;<br />
mysql> SELECT COUNT(*) FROM city;<br />
<br />
</code>
</div>
<div><br /></div></div>Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-85398858662604183362020-09-22T01:42:00.003+08:002020-09-22T01:42:32.341+08:00MySQL mysql_config_editor与期望 <p> 这只是一条注释,旨在帮助可能会在其自动化工具中使用mysql_config_editor命令的任何人。 </p><p><span style="vertical-align: inherit;">mysql_config_editor不使用密码参数,因此在尝试使用mysql_config_editor的.my.cnf文件中设置密码之前可能拥有的自动化工具会失败。 </span></p><p><span style="vertical-align: inherit;">尽管使用期望工具,这是可能的并且非常简单。 </span></p><p></p><div class="</code></div>ox"><code><p></p><p> yum -y install expect </p></code><p><code></code></p></div><p></p><p><span style="vertical-align: inherit;">它也适用于apt-get。 </span></p><p><br /></p><p><span style="vertical-align: inherit;">因此,在此示例中,我将显示一个简单的bash脚本版本。 </span></p><p><span style="vertical-align: inherit;">1 ..我的登录路径不起作用... </span></p><p></p><div class="</code></div>ox"><code><p></p><p>mysql --login-path=local</p><p>ERROR 1045 (28000): Access denied for user</p></code><p><code></code></p></div><p></p><p><br /></p><p><span style="vertical-align: inherit;">设置这个与期望 </span></p><p><span style="vertical-align: inherit;">您可以通过bash脚本执行此操作。 </span></p><p></p><div class="</code></div>ox"><code><p></p><p>expect <<EOD</p><p>spawn mysql_config_editor set --login-path=local --host=localhost --user=root --password </p><p>expect "password"</p><p>send -- "<PASSWORD>\r"</p><p>interact</p><p>EOD</p></code><p><code></code></p></div><p></p><p><br /></p><p><span style="vertical-align: inherit;">现在可以了...</span></p><p></p><div class="</code></div>ox"><code><p></p><p>mysql --login-path=local</p><p>Welcome to the MySQL monitor. Commands end with ; or \g.</p><p>Your MySQL connection id is 1002</p></code></div>Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-67782927554113116022020-03-16T06:15:00.001+08:002020-03-16T06:15:20.339+08:00MySQL和Docker ...一個簡單的設置<div dir="ltr" style="text-align: left;" trbidi="on">
<span class="notranslate">MySQL和Docker ...不是新概念,人們已經使用Docker已有一段時間了。</span> <span class="notranslate">對於剛開始為此發展的人來說,可能會有一些障礙。</span> <br /><br /> <span class="notranslate">儘管MySQL在本地運行良好,但如果要在不同版本的MySQL上測試代碼,則很容易擁有多個版本是很好的。</span> <br /><br /> <span class="notranslate">多年來,一種選擇當然是Giuseppe Maxia的<a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=https://mysqlsandbox.net/&usg=ALkJrhiEDIt_cXC78dvv62fo0U2X2E2QUQ">https://mysqlsandbox.net/</a> 。</span> <span class="notranslate">這是一個非常有效的解決方案,能夠啟動多個實例並測試複製等。</span> <br /><br /> <span class="notranslate">在跨不同版本的MySQL進行測試時,Docker現在也是另一個經常使用的場景。</span> <span class="notranslate">下面僅介紹一些步驟,以輕鬆安裝多個版本。</span> <span class="notranslate">我使用OSX,因此這些示例適用於OSX。</span> <br /><br /> <span class="notranslate">您需要Docker才能啟動,當然,Docker Desktop是一個方便的工具,使您能夠輕鬆獲得訪問權限。</span> <br /><br />
<ul>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=https://docs.docker.com/docker-for-mac/install/&usg=ALkJrhjNKP9N6xk25MFw_a59gdlJ7Nvjyg">https://docs.docker.com/docker-for-mac/install/</a></span> </li>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=https://docs.docker.com/docker-for-windows/&usg=ALkJrhizz0CmByVep6mSgFbKX2jQb3eKGA">https://docs.docker.com/docker-for-windows/</a></span> </li>
</ul>
<div>
<span class="notranslate">設置好Docker之後,就可以為MySQL準備好環境了。</span> </div>
<div>
<br /></div>
<div>
<span class="notranslate">在這裡,我創建了一個Docker文件夾,其中包含MySQL數據目錄,配置文件以及mysql-files目錄(如果需要)。</span> </div>
<div class="codebox">
<code>
</code><br /><div>
<code>mkdir ~/Docker ;</code> </div>
<code>
</code><br /><div>
<code>mkdir ~/Docker/mysql_data;</code> </div>
<code>
</code><div>
<code>mkdir ~/Docker/mysql-files;</code> </div>
<div>
<code>mkdir ~/Docker/cnf;</code> </div>
</div>
<div>
<br /></div>
<div>
<span class="notranslate">現在在mysql_data</span> </div>
<br />
<div class="codebox">
<code>
</code><br /><div>
<div>
<code>cd ~/Docker/mysql_data;</code> </div>
<div>
<code>mkdir 8.0;</code> </div>
<div>
<code>mkdir 5.7;</code> </div>
<div>
<code>mkdir 5.6;</code> </div>
<div>
<code>mkdir 5.5;</code> </div>
</div>
</div>
<div>
<br /></div>
<div>
<br /><div>
<span class="notranslate">現在,我為該示例設置簡單的cnf文件。</span> <span class="notranslate">要注意的主要事情是綁定地址。</span> <span class="notranslate">這樣做是為了確保它對我們開放,使其可以在docker之外訪問MySQL。</span> <span class="notranslate">您還可以注意到,對於每個MySQL docker實例,這些文件都可以用來設置其他配置信息。</span> </div>
<div>
<br /></div>
<br /><div class="codebox">
<code>
</code><br /><div>
<div>
<code>cd ~/Docker/cnf;</code> </div>
<div>
<code><br /></code> </div>
<div>
<div>
<code>cat my.8.0.cnf</code> </div>
<div>
<code>[mysqld]</code> </div>
<div>
<code>pid-file = /var/run/mysqld/mysqld.pid</code> </div>
<div>
<code>socket = /var/run/mysqld/mysqld.sock</code> </div>
<div>
<code>datadir = /var/lib/mysql</code> </div>
<div>
<code>secure-file-priv= /var/lib/mysql-files</code> </div>
<div>
<code># Disabling symbolic-links is recommended to prevent assorted security risks</code> </div>
<div>
<code>symbolic-links=0</code> </div>
<div>
<code>bind-address = 0.0.0.0</code> </div>
<div>
<code>port=3306</code> </div>
<div>
<code>server-id=80</code> </div>
<div>
<code><br /></code> </div>
<div>
<code><br /></code> </div>
<div>
<code># Custom config should go here</code> </div>
<div>
<code>!includedir /etc/mysql/conf.d/</code> </div>
</div>
<div>
<code><br /></code> </div>
<div>
<div>
<code>cat my.5.7.cnf</code> </div>
<div>
<code>[mysqld]</code> </div>
<div>
<code>bind-address = 0.0.0.0</code> </div>
<div>
<code>server-id=57</code> </div>
<div>
<code>max_allowed_packet=32M</code> </div>
</div>
<div>
<code><br /></code> </div>
<div>
<code>$ cat my.5.6.cnf</code> </div>
<div>
<div>
<code>[mysqld]</code> </div>
<div>
<code>bind-address = 0.0.0.0</code> </div>
<div>
<code>server-id=56</code> </div>
</div>
<div>
<code><br /></code> </div>
<div>
<code>$ cat my.5.5.cnf</code> </div>
<div>
<div>
<code>[mysqld]</code> </div>
<div>
<code>bind-address = 0.0.0.0</code> </div>
<div>
<code>server-id=55</code> </div>
</div>
</div>
</div>
</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<span class="notranslate">好的,現在我們已經設置了配置文件,我們需要構建docker。</span> <span class="notranslate">生成命令要注意的幾件事。</span> </div>
<div>
<br /></div>
<div>
<span class="notranslate"> --name我們為docker設置了一個命名引用。</span> </div>
<div>
<br /></div>
<div>
<span class="notranslate">在這裡,我們將配置文件,數據目錄和mysql-files目錄映射到docker。</span> <span class="notranslate">這使我們可以輕鬆調整my.cnf文件等。</span> </div>
<div>
<span class="notranslate"> -v〜/ Docker / cnf / my.8.0.cnf:/etc/mysql/my.cnf</span> </div>
<div>
<span class="notranslate"> -v〜/ Docker / mysql_data / 8.0:/ var / lib / mysql</span> </div>
<div>
<span class="notranslate"> -v〜/ Docker / mysql文件:/ var / lib / mysql文件</span> </div>
<div>
<br /></div>
<div>
<span class="notranslate">我們希望能夠在docker之外訪問這些MySQL實例,因此我們需要相應地發布和映射端口。</span> </div>
<div>
<span class="notranslate"> -p 3306:3306這意味著3306在docker內部的3306本地</span> </div>
<div>
<span class="notranslate"> -p 3307:3306這意味著3307在docker內部3306本地</span> </div>
<div>
<span class="notranslate"> -p 3308:3306這意味著3308在docker內部3306本地</span> </div>
<div>
<span class="notranslate"> -p 3309:3306這意味著3309在docker內部3306本地</span> </div>
<div>
<br /></div>
<div>
<span class="notranslate">然後,我們還要傳遞幾個環境變量。</span> </div>
<div>
<span class="notranslate"> -e MYSQL_ROOT_HOST =%-e MYSQL_ROOT_PASSWORD = <在此處設置密碼></span> </div>
<div>
<br /></div>
<div>
<span class="notranslate">所以放在一起...</span> </div>
<div>
<br /></div>
<div>
<div class="codebox">
<code>
</code><br /><div>
<div>
<code>docker run --restart always --name
mysql8.0 -v ~/Docker/cnf/my.8.0.cnf:/etc/mysql/my.cnf -v
~/Docker/mysql_data/8.0:/var/lib/mysql -v
~/Docker/mysql-files:/var/lib/mysql-files -p 3306:3306 -d -e
MYSQL_ROOT_HOST=% -e MYSQL_ROOT_PASSWORD=<set a password here>
mysql:8.0</code> </div>
<div>
<code><br /></code> </div>
<div>
<code>docker
run --restart always --name mysql5.7 -v
~/Docker/cnf/my.5.7.cnf:/etc/mysql/my.cnf -v
~/Docker/mysql_data/5.7:/var/lib/mysql -v
~/Docker/mysql-files:/var/lib/mysql-files -p 3307:3306 -d -e
MYSQL_ROOT_HOST=% -e MYSQL_ROOT_PASSWORD=<set a password here>
mysql:5.7</code> </div>
<div>
<code><br /></code> </div>
<div>
<code>docker
run --restart always --name mysql5.6 -v
~/Docker/cnf/my.5.6.cnf:/etc/mysql/my.cnf -v
~/Docker/mysql_data/5.6:/var/lib/mysql -v
~/Docker/mysql-files:/var/lib/mysql-files -p 3308:3306 -d -e
MYSQL_ROOT_HOST=% -e MYSQL_ROOT_PASSWORD=<set a password here>
mysql:5.6</code> </div>
<div>
<code><br /></code> </div>
<div>
<code>docker
run --restart always --name mysql5.5 -v
~/Docker/cnf/my.5.5.cnf:/etc/mysql/my.cnf -v
~/Docker/mysql_data/5.5:/var/lib/mysql -v
~/Docker/mysql-files:/var/lib/mysql-files -p 3309:3306 -d -e
MYSQL_ROOT_HOST=% -e MYSQL_ROOT_PASSWORD=<set a password here>
mysql:5.5</code> </div>
</div>
</div>
</div>
<div>
<br /></div>
<div>
<span class="notranslate">每次執行以上命令後,您都應該返回一個ID。</span> </div>
<div>
<span class="notranslate">示例:3cb07d7c21476fbf298648986208f3429ec664167d8eef7fed17bf9ee3ce6316</span> </div>
<div>
<br /></div>
<div>
<span class="notranslate">您可以通過Docker桌面輕鬆啟動/重新啟動和訪問每個Docker終端,或者只需記下相關ID即可通過終端執行。</span> <br /><br /><div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguzkBZywA60b4D0lvweJk_9xD8s-9628iej_bzoT5v1OKMcCHdH00WFQ3RTVrTjPJ5iVy1-cAvL4t_7I24IWRmYYpWkDPMf3xqIy-JkOQcI1hltOrh_QlBLAc99ooZq0NSU4GpaAWD6SQ/s1600/Screen+Shot+2020-03-15+at+4.01.31+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="485" data-original-width="853" height="226" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguzkBZywA60b4D0lvweJk_9xD8s-9628iej_bzoT5v1OKMcCHdH00WFQ3RTVrTjPJ5iVy1-cAvL4t_7I24IWRmYYpWkDPMf3xqIy-JkOQcI1hltOrh_QlBLAc99ooZq0NSU4GpaAWD6SQ/s400/Screen+Shot+2020-03-15+at+4.01.31+PM.png" width="400" /></a> </div>
<div class="separator" style="clear: both; text-align: center;">
<span class="notranslate"> Docker桌面還會顯示您傳遞的所有變量,以便您進行驗證。</span> </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeU6hEzwZvm9PPuS-4-Gl0CfnahC1jBuWzMNIc95CY0O2TddmIFl8538OWDR4fKCex7JajLsuu5wMdLHABm8__8guPMDRDD5SG_5IoTpTxSck8vuKhRr6fXzUthA_sSW17znlr-jFsjR8/s1600/Screen+Shot+2020-03-15+at+4.04.04+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="53" data-original-width="249" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeU6hEzwZvm9PPuS-4-Gl0CfnahC1jBuWzMNIc95CY0O2TddmIFl8538OWDR4fKCex7JajLsuu5wMdLHABm8__8guPMDRDD5SG_5IoTpTxSck8vuKhRr6fXzUthA_sSW17znlr-jFsjR8/s1600/Screen+Shot+2020-03-15+at+4.04.04+PM.png" /></a> </div>
<div class="separator" style="clear: both; text-align: center;">
<span class="notranslate">當然,您也可以在此處訪問CLI,輕鬆停止或啟動或銷毀它。</span> </div>
</div>
<div>
<br /></div>
<div class="codebox">
<code>
</code><br /><div>
<div class="p1" style="font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<code><span class="s1" style="font-variant-ligatures: no-common-ligatures;">$ docker exec -it 3cb07d7c21476fbf298648986208f3429ec664167d8eef7fed17bf9ee3ce6316 /bin/sh; exit</span></code> </div>
<div class="p1" style="font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<code><span class="s1" style="font-variant-ligatures: no-common-ligatures;"># mysql -p</span></code> </div>
</div>
<code>
</code></div>
<div>
<br /></div>
<div>
<span class="notranslate">如果Docker容器已經在運行,您現在可以通過localhost終端訪問MySQL。</span> </div>
<div>
<div class="codebox">
<code>
</code><br /><div>
<div class="p1" style="font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<code><span class="s1" style="font-family: "menlo"; font-size: 11px;">$</span> <span style="font-family: "menlo";"><span style="font-size: 11px; font-variant-ligatures: no-common-ligatures;">mysql --host=localhost --protocol=tcp --port=3306 -p -u root</span></span></code> </div>
</div>
<code>
</code></div>
</div>
<div>
<br /></div>
<div>
<span class="notranslate">現在,如果您遇到任何訪問問題,請記住確保MySQL帳戶正確並且您的端口和映射正確。</span> </div>
<div>
<ul>
<li> <span class="notranslate">在“讀取初始通信數據包”時失去與MySQL服務器的連接</span> </li>
<li> <span class="notranslate">錯誤1045(28000):用戶'root'@'192.168.0.5'的訪問被拒絕(使用密碼:是)</span> </li>
</ul>
</div>
<div>
<br /> <span class="notranslate">現在,您可以看到所有設備均已啟動並且可用,並且服務器ID與我們為每個cnf文件的eariler設置的設置匹配。</span> </div>
<div>
<br /></div>
<div class="codebox">
<code>$ mysql --host=localhost --protocol=tcp --port=3306 -e "Select @@hostname, @@version, @@server_id " <br /> +--------------+-----------+-------------+ <br /> | @@hostname | @@version | @@server_id | <br /> +--------------+-----------+-------------+ <br /> | 58e9663afe8d | 8.0.19 | 80 | <br /> +--------------+-----------+-------------+ <br /> $ mysql --host=localhost --protocol=tcp --port=3307 -e "Select @@hostname, @@version, @@server_id " <br /> +--------------+-----------+-------------+ <br /> | @@hostname | @@version | @@server_id | <br /> +--------------+-----------+-------------+ <br /> | b240917f051a | 5.7.29 | 57 | <br /> +--------------+-----------+-------------+ <br /> $ mysql --host=localhost --protocol=tcp --port=3308 -e "Select @@hostname, @@version, @@server_id " <br /> +--------------+-----------+-------------+ <br /> | @@hostname | @@version | @@server_id | <br /> +--------------+-----------+-------------+ <br /> | b4653850cfe9 | 5.6.47 | 56 | <br /> +--------------+-----------+-------------+ <br /> $ mysql --host=localhost --protocol=tcp --port=3309 -e "Select @@hostname, @@version, @@server_id " <br /> +--------------+-----------+-------------+ <br /> | @@hostname | @@version | @@server_id | <br /> +--------------+-----------+-------------+ <br /> | 22e169004583 | 5.5.62 | 55 | <br /> +--------------+-----------+-------------+ </code> </div>
<div>
<br /></div>
<div>
<br /></div>
</div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-43997851237880845382019-07-13T13:27:00.001+08:002019-07-13T13:27:07.192+08:00MySQL如何恢復表空間<div dir="ltr" style="text-align: left;" trbidi="on">
<span class="notranslate">MySQL如何恢復表空間?</span> <br /><br /> <span class="notranslate">這不是新的信息,但我沒有多說,所以現在為那些需要它的人解決它。</span> <br /><br /> <span class="notranslate">如果您丟失了ibd文件......您將丟失數據。</span> <span class="notranslate">因此,如果您有一個可用的副本..或者即使您從另一個數據庫同步,您仍然可以導入它。</span> <span class="notranslate">什麼/你如何失去表空間?</span> <br /><br /> <span class="notranslate">這是一個恢復表空間的簡單示例。</span> <br /><br />
<div class="codebox">
<code><br /> <br /> mysql> Create database demo; <br /> <br /> mysql> use demo; <br /> <br /> mysql> CREATE TABLE `demotable` ( <br /> -> `id` int(11) NOT NULL AUTO_INCREMENT, <br /> -> `dts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, <br /> -> PRIMARY KEY (`id`) <br /> -> ) ENGINE=InnoDB; </code> </div>
<br /><br /> <span class="notranslate">現在我們存儲一些數據......</span> <br /><br />
<div class="codebox">
<code><br /> mysql> INSERT INTO demotable (id) VALUES (NULL); <br /> Query OK, 1 row affected (0.10 sec) <br /> <br /> mysql> INSERT INTO demotable (id) VALUES (NULL); <br /> Query OK, 1 row affected (0.08 sec) <br /> <br /> mysql> SELECT * FROM demotable; <br /> +----+---------------------+ <br /> | id | dts | <br /> +----+---------------------+ <br /> | 1 | 2019-07-12 23:31:34 | <br /> | 2 | 2019-07-12 23:31:35 | <br /> +----+---------------------+ <br /> 2 rows in set (0.00 sec) </code> </div>
<br /><br /> <span class="notranslate">好的,現在讓我們打破它..</span> <br /><br />
<div class="codebox">
<code><br /> # systemctl stop mysqld <br /> # cd /var/lib/mysql/demo/ <br /> # ls -ltr <br /> total 80 <br /> -rw-r-----. 1 mysql mysql 114688 Jul 12 23:31 demotable.ibd <br /> # mv demotable.ibd /tmp/ <br /> <br /> # systemctl start mysqld <br /> # mysql demo <br /> <br /> mysql> show tables; <br /> +----------------+ <br /> | Tables_in_demo | <br /> +----------------+ <br /> | demotable | <br /> +----------------+ <br /> 1 row in set (0.00 sec) <br /> <br /> mysql> desc demotable; <br /> +-------+-----------+------+-----+-------------------+-----------------------------------------------+ <br /> | Field | Type | Null | Key | Default | Extra | <br /> +-------+-----------+------+-----+-------------------+-----------------------------------------------+ <br /> | id | int(11) | NO | PRI | NULL | auto_increment | <br /> | dts | timestamp | NO | | CURRENT_TIMESTAMP | DEFAULT_GENERATED on update CURRENT_TIMESTAMP | <br /> +-------+-----------+------+-----+-------------------+-----------------------------------------------+ <br /> 2 rows in set (0.01 sec) <br /> <br /> mysql> INSERT INTO demotable (id) VALUES (NULL); <br /> ERROR 1812 (HY000): Tablespace is missing for table `demo`.`demotable`. </code> </div>
<br /><br /> <span class="notranslate">破損和丟失的表空間......現在我們可以恢復它了..</span> <br /><br />
<div class="codebox">
<code><br /> demo]# cp /tmp/demotable.ibd . <br /> <br /> mysql> ALTER TABLE demotable DISCARD TABLESPACE; <br /> <br /> demo]# cp /tmp/demotable.ibd . <br /> demo]# ls -ltr <br /> total 112 <br /> -rw-r-----. 1 root root 114688 Jul 12 23:50 demotable.ibd <br /> demo]# chown mysql:mysql demotable.ibd <br /> demo]# mysql demo <br /> mysql> ALTER TABLE demotable IMPORT TABLESPACE; <br /> ERROR 1034 (HY000): Incorrect key file for table 'demotable'; try to repair it <br /> <br /> mysql> REPAIR TABLE demotable; <br /> +----------------+--------+----------+---------------------------------------------------------+ <br /> | Table | Op | Msg_type | Msg_text | <br /> +----------------+--------+----------+---------------------------------------------------------+ <br /> | demo.demotable | repair | note | The storage engine for the table doesn't support repair | <br /> +----------------+--------+----------+---------------------------------------------------------+ </code> </div>
<br /><br /> <span class="notranslate">現在註意我們還有另一個錯誤..這通常與tmpdir可用的空間有關,而且無論如何修復都不適用於.ibd。</span> <br /><br />
<div class="codebox">
<code><br /> mysql> select @@tmpdir; <br /> +----------+ <br /> | @@tmpdir | <br /> +----------+ <br /> | /tmp | <br /> +----------+ <br /> <br /> # vi /etc/my.cnf <br /> tmpdir=/var/lib/mysql-files/ <br /> <br /> # systemctl restart mysqld <br /> # mysql demo </code> </div>
<br /><br /> <span class="notranslate"> OK只使用了mysql-files目錄。</span> <br /> <span class="notranslate">現在我們可以再試一次。</span> <br /><br />
<div class="codebox">
<code><br /> mysql> ALTER TABLE demotable IMPORT TABLESPACE; <br /> Query OK, 0 rows affected, 1 warning (0.61 sec) <br /> <br /> mysql> INSERT INTO demotable (id) VALUES (NULL); <br /> Query OK, 1 row affected (0.11 sec) <br /> <br /> mysql> SELECT * FROM demotable; <br /> +----+---------------------+ <br /> | id | dts | <br /> +----+---------------------+ <br /> | 1 | 2019-07-12 23:31:34 | <br /> | 2 | 2019-07-12 23:31:35 | <br /> | 3 | 2019-07-12 23:56:08 | <br /> +----+---------------------+ </code> </div>
<br /><br /> <span class="notranslate">好的工作。</span> <br /> <span class="notranslate">現在,如果您只有一張桌子,這一切都很簡單。</span> <span class="notranslate">但是100多歲......</span> <br /><br /> <span class="notranslate">當然,自動化它,並使用您的information_schema來提供幫助。</span> <br /><br /> <span class="notranslate">再做幾個副本進行測試。</span> <br />
<div class="codebox">
<code><br /> mysql> create table demotable1 like demotable; <br /> Query OK, 0 rows affected (0.51 sec) <br /> <br /> mysql> create table demotable2 like demotable; <br /> Query OK, 0 rows affected (1.04 sec) <br /> <br /> mysql> create table demotable3 like demotable; <br /> Query OK, 0 rows affected (0.74 sec) <br /> <br /> mysql> create table demotable4 like demotable; <br /> Query OK, 0 rows affected (2.21 sec) </code> </div>
<br /><br /> <span class="notranslate">打破他們所有..</span> <br />
<div class="codebox">
<code><br /> demo]# mv *.ibd /tmp/ </code> </div>
<br /><br /> <span class="notranslate">現在使用您的information_schema.tables表,您可以構建所需的所有命令。</span> <br />
<div class="codebox">
<code><br /> # vi build_discard.sql <br /> # cat build_discard.sql <br />
SELECT CONCAT(" ALTER TABLE ",TABLE_SCHEMA,".",TABLE_NAME," DISCARD
TABLESPACE; ") as CMD FROM information_schema.TABLES WHERE
TABLE_SCHEMA='demo'; <br /> <br /> # vi build_import.sql <br /> # cat build_import.sql <br />
SELECT CONCAT(" ALTER TABLE ",TABLE_SCHEMA,".",TABLE_NAME," IMPORT
TABLESPACE; ") as CMD FROM information_schema.TABLES WHERE
TABLE_SCHEMA='demo'; </code> </div>
<br /><br />
<div class="codebox">
<code><br /> # mysql -N < build_import.sql > import_tablespace.sql <br /> # mysql -N < build_discard.sql | mysql demo <br /> <br /> demo]# cp /tmp/*.ibd . <br /> demo]# chown mysql:mysql *.ibd <br /> # systemctl restart mysqld <br /> # mysql demo < import_tablespace.sql <br /> # mysql demo <br /> <br /> mysql> INSERT INTO demotable (id) VALUES (NULL); <br /> Query OK, 1 row affected (0.08 sec) <br /> <br /> mysql> INSERT INTO demotable1 (id) VALUES (NULL); <br /> Query OK, 1 row affected (0.05 sec) <br /> <br /> mysql> INSERT INTO demotable2 (id) VALUES (NULL); <br /> Query OK, 1 row affected (0.09 sec) <br /> <br /> mysql> INSERT INTO demotable3 (id) VALUES (NULL); <br /> ^[[AQuery OK, 1 row affected (0.37 sec) <br /> <br /> mysql> INSERT INTO demotable4 (id) VALUES (NULL); <br /> Query OK, 1 row affected (0.12 sec) </code> <br /><div>
</div>
</div>
<br /><br /> <span class="notranslate">它奏效了。</span> </div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-15032662184863450802019-07-13T12:46:00.001+08:002019-07-13T12:46:44.589+08:00MySQL Binlogs ::如何恢復<div dir="ltr" style="text-align: left;" trbidi="on">
<span class="notranslate">所以我意識到在最近出現這種情況後我沒有發表過關於此的帖子。</span> <br /><br /> <span class="notranslate">以下是場景:在午夜進行備份,他們使用每個數據庫的MySQL轉儲。</span> <span class="notranslate">然後在第二天上午十點數據庫崩潰。</span> <span class="notranslate">在我被調用之前發生了一系列事件,但他們把它帶到了MyISAM表的數據庫版本和表空間中缺少的IBD文件。</span> <br /><br /> <span class="notranslate">所以選項1,從備份恢復會讓我們到午夜,我們會丟失數小時的數據。</span> <span class="notranslate">選項2,我們重新導入1000的ibd文件並保留所有內容。</span> <span class="notranslate">然後我們有選項3,從備份恢復,然後應用binlogs進行最近的更改。</span> <br /><br /> <span class="notranslate">為了使它更有趣,他們沒有我被告知的所有ibd文件,我確實看到一些丟失。</span> <span class="notranslate">所以不確定這是怎麼可能的,但是選項2變成了無效選項。</span> <span class="notranslate">當然,他們希望盡可能減少數據丟失,因此我們選擇了3。</span> <br /><br /> <span class="notranslate">為了安全地做到這一點,我在端口3307下啟動了另一個MySQL實例。這使我有了一個安全的工作場所,同時流量對端口3306實例上的MyISAM數據具有讀訪問權限。</span> <br /><br /> <span class="notranslate">一旦所有備份轉儲文件解壓縮並導入3307實例,我就可以專注於binlog文件。</span> <br /><br /> <span class="notranslate">起初,這個概念聽起來比實際風險要大得多。</span> <span class="notranslate">它實際上很簡單直接。</span> <br /><br /> <span class="notranslate">首先,您必須找到您之後的數據。</span> <span class="notranslate">通過查看binlog文件,您可以了解哪些文件是相關的。</span> <span class="notranslate">在我的情況下,他們設法重置了binlog,因此117文件中有2個日期範圍。</span> <br /><br /> <span class="notranslate">首先對於binlog審查,以下命令以人類可讀的格式輸出數據。</span> <br />
<div class="codebox">
<code>mysqlbinlog
--defaults-file=/root/.my.cnf --base64-output=DECODE-ROWS --verbose
mysql-bin.000117 > review_mysql-bin.000117.sql </code> </div>
<br /> <span class="notranslate"> *注意......小心運行上面的命令。</span> <span class="notranslate">請注意,我將文件直接轉儲到binlog所在的位置。</span> <span class="notranslate">因此,確認您的文件名有效。</span> <span class="notranslate">這個mysql-bin.000117.sql與這個mysql-bin.000117 .sql不同。</span> <span class="notranslate">您將使用第二個選項和.sql之前的空格來丟失binlog。</span> <br /><br /> <span class="notranslate">現在保存數據,以便可以應用它。</span> <span class="notranslate">由於我有幾個binlogs,我創建了一個文件,我想要仔細檢查時間範圍。</span> <br /><br />
<div class="codebox">
<code><br />
mysqlbinlog --defaults-file=/root/.my.cnf --start-datetime="2019-07-09
00:00:00" --stop-datetime="2019-07-10 00:00:00" mysql-bin.000117 >
binlog_restore.sql <br /> mysqlbinlog --defaults-file=/root/.my.cnf mysql-bin.000118 >> binlog_restore.sql <br /> mysqlbinlog --defaults-file=/root/.my.cnf mysql-bin.000119 >> binlog_restore.sql <br />
mysqlbinlog --defaults-file=/root/.my.cnf --start-datetime="2019-07-10
00:00:00" --stop-datetime="2019-07-10 10:00:00" mysql-bin.000117
>> binlog_restore.sql <br /> mysqlbinlog --defaults-file=/root/.my.cnf --stop-datetime="2019-07-10 10:00:00" mysql-bin.000120 >> binlog_restore.sql <br /> mysqlbinlog --defaults-file=/root/.my.cnf --stop-datetime="2019-07-10 10:00:00" mysql-bin.000121 >> binlog_restore.sql <br /> <br /> mysql --socket=/var/lib/mysql_restore/mysql.sock -e "source /var/lib/mysql/binlog_restore.sql" <br /> </code> </div>
<br /> <span class="notranslate">現在我將這些binlog中的所有數據應用於給定的時間範圍。</span> <span class="notranslate">客戶端仔細檢查了所有數據,並非常高興能夠全部恢復。</span> <br /><br /> <span class="notranslate">對於這種情況存在幾種不同的選擇,這恰好與客戶一起鍛煉。</span> <br /><br /> <span class="notranslate">一旦驗證的all在恢復的版本上沒問題,它就是一個簡單的停止兩個數據庫,移動數據目錄(想要保持datadir默認完整),chown目錄只是為了安全並啟動MySQL。</span> <span class="notranslate">現在,已恢復的實例已在端口3306上啟動。</span> <br /></div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-30367180371463468662019-06-17T21:01:00.001+08:002019-06-17T21:01:36.208+08:00MySQL組複製<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" trbidi="on">
<span class="notranslate">所以MySQL的組複製出來了MySQL 5.7。</span> <span class="notranslate">現在已經有一段時間了,人們開始更多地詢問它。</span> <br /><ul>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/8.0/en/group-replication.html&xid=17259,15700021,15700186,15700191,15700256,15700259&usg=ALkJrhhOkaKJYw5H5g_Ikz6OCtSTw0ibXQ">https://dev.mysql.com/doc/refman/8.0/en/group-replication.html</a></span> </li>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/8.0/en/group-replication-deploying-in-single-primary-mode.html&xid=17259,15700021,15700186,15700191,15700256,15700259&usg=ALkJrhgxwQ09gtIDRyGAaD9x96Qf2LxJ9g">https://dev.mysql.com/doc/refman/8.0/en/group-replication-deploying-in-single-primary-mode.html</a></span> </li>
</ul>
<span class="notranslate">下面是一個如何設置它的例子和一些痛點的例子,因為我用它來探討。</span> <br /> <span class="notranslate">我使用三個不同的服務器,</span> <br /><br /> <span class="notranslate">服務器CENTOSA</span> <br /><div class="codebox">
<code><br /> mysql> INSTALL PLUGIN group_replication SONAME 'group_replication.so'; <br /> Query OK, 0 rows affected (0.02 sec) <br /> <br /> vi my.cnf <br /> disabled_storage_engines="MyISAM,BLACKHOLE,FEDERATED,ARCHIVE,MEMORY" <br /> server_id=1 <br /> gtid_mode=ON <br /> enforce_gtid_consistency=ON <br /> binlog_checksum=NONE <br /> <br /> log_bin=binlog <br /> log_slave_updates=ON <br /> binlog_format=ROW <br /> master_info_repository=TABLE <br /> relay_log_info_repository=TABLE <br /> <br /> transaction_write_set_extraction=XXHASH64 <br /> group_replication_group_name="90d8b7c8-5ce1-490e-a448-9c8d176b54a8" <br /> group_replication_start_on_boot=off <br /> group_replication_local_address= "192.168.111.17:33061" <br /> group_replication_group_seeds= "192.168.111.17:33061,192.168.111.89:33061,192.168.111.124:33061" <br /> group_replication_bootstrap_group=off <br /> <br /> mysql> SET SQL_LOG_BIN=0; <br /> mysql> CREATE USER repl@'%' IDENTIFIED BY 'replpassword'; <br /> mysql> GRANT REPLICATION SLAVE ON *.* TO repl@'%'; <br /> mysql> FLUSH PRIVILEGES; <br /> mysql> SET SQL_LOG_BIN=1; <br /> <br /> <br /> CHANGE MASTER TO <br /> MASTER_USER='repl', <br /> MASTER_PASSWORD='replpassword' <br /> FOR CHANNEL 'group_replication_recovery'; <br /> <br /> <br /> mysql> SET GLOBAL group_replication_bootstrap_group=ON; <br /> Query OK, 0 rows affected (0.00 sec) <br /> <br /> <br /> mysql> START GROUP_REPLICATION; <br /> Query OK, 0 rows affected (3.11 sec) <br /> <br /> <br /> mysql> SET GLOBAL group_replication_bootstrap_group=OFF; <br /> Query OK, 0 rows affected (0.00 sec) <br /> <br /> <br /> mysql> SELECT * FROM performance_schema.replication_group_members \G <br /> <br /> *************************** 1. row *************************** <br /> CHANNEL_NAME: group_replication_applier <br /> MEMBER_ID: 1ab30239-5ef6-11e9-9b4a-08002712f4b1 <br /> MEMBER_HOST: centosa <br /> MEMBER_PORT: 3306 <br /> MEMBER_STATE: ONLINE <br /> MEMBER_ROLE: PRIMARY <br /> MEMBER_VERSION: 8.0.15 <br /> </code> </div>
<span class="notranslate">所以現在我們可以添加更多服務器。</span> <br /> <span class="notranslate">服務器CENTOSB</span> <br /><ul>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/8.0/en/group-replication-adding-instances.html&xid=17259,15700021,15700186,15700191,15700256,15700259&usg=ALkJrhggsN6Hu069AUqouvF6PMPGC8ATVg" target="_blank">https://dev.mysql.com/doc/refman/8.0/en/group-replication-adding-instances.html</a></span> </li>
</ul>
<br /><div class="codebox">
<code>vi my.cnf <br /> disabled_storage_engines="MyISAM,BLACKHOLE,FEDERATED,ARCHIVE,MEMORY" <br /> server_id=2 <br /> gtid_mode=ON <br /> enforce_gtid_consistency=ON <br /> binlog_checksum=NONE <br /> <br /> log_bin=binlog <br /> log_slave_updates=ON <br /> binlog_format=ROW <br /> master_info_repository=TABLE <br /> relay_log_info_repository=TABLE <br /> <br /> <br /> transaction_write_set_extraction=XXHASH64 <br /> group_replication_group_name="90d8b7c8-5ce1-490e-a448-9c8d176b54a8" <br /> group_replication_start_on_boot=off <br /> group_replication_local_address= "192.168.111.89:33061" <br /> group_replication_group_seeds= "192.168.111.17:33061,192.168.111.89:33061,192.168.111.124:33061" <br /> group_replication_bootstrap_group=off <br /> <br /> mysql> CHANGE MASTER TO <br /> MASTER_USER='repl', <br /> MASTER_PASSWORD='replpassword' <br /> FOR CHANNEL 'group_replication_recovery'; <br /> Query OK, 0 rows affected, 2 warnings (0.02 sec) <br /> <br /> mysql> CHANGE MASTER TO GET_MASTER_PUBLIC_KEY=1; <br /> Query OK, 0 rows affected (0.02 sec) <br /> <br /> mysql> START GROUP_REPLICATION; <br /> Query OK, 0 rows affected (4.03 sec) <br /> <br /> mysql> SELECT * FROM performance_schema.replication_group_members; <br />
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
<br /> | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION | <br />
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
<br /> | group_replication_applier | 1ab30239-5ef6-11e9-9b4a-08002712f4b1 | centosa | 3306 | ONLINE | PRIMARY | 8.0.15 | <br /> | group_replication_applier | 572ca2fa-5eff-11e9-8df9-08002712f4b1 | centosb | 3306 | RECOVERING | SECONDARY | 8.0.15 | <br />
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
<br /> 2 rows in set (0.00 sec) </code> </div>
<br /><br /> <span class="notranslate">服務器CENTOSC</span> <br /><ul>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/8.0/en/group-replication-adding-instances.html&xid=17259,15700021,15700186,15700191,15700256,15700259&usg=ALkJrhggsN6Hu069AUqouvF6PMPGC8ATVg" target="_blank">https://dev.mysql.com/doc/refman/8.0/en/group-replication-adding-instances.html</a></span> </li>
</ul>
<br /><div class="codebox">
<code>vi my.cnf <br /> disabled_storage_engines="MyISAM,BLACKHOLE,FEDERATED,ARCHIVE,MEMORY" <br /> server_id=3 <br /> gtid_mode=ON <br /> enforce_gtid_consistency=ON <br /> binlog_checksum=NONE <br /> log_bin=binlog <br /> log_slave_updates=ON <br /> binlog_format=ROW <br /> master_info_repository=TABLE <br /> relay_log_info_repository=TABLE <br /> <br /> transaction_write_set_extraction=XXHASH64 <br /> group_replication_group_name="90d8b7c8-5ce1-490e-a448-9c8d176b54a8" <br /> group_replication_start_on_boot=off <br /> group_replication_local_address= "192.168.111.124:33061" <br /> group_replication_group_seeds= "192.168.111.17:33061,192.168.111.89:33061,192.168.111.124:33061" <br /> group_replication_bootstrap_group=off <br /> <br /> mysql> CHANGE MASTER TO <br /> -> MASTER_USER='repl', <br /> -> MASTER_PASSWORD='replpassword' <br /> -> FOR CHANNEL 'group_replication_recovery'; <br /> Query OK, 0 rows affected, 2 warnings (0.02 sec) <br /> <br /> mysql> CHANGE MASTER TO GET_MASTER_PUBLIC_KEY=1; <br /> Query OK, 0 rows affected (0.02 sec) <br /> <br /> mysql> START GROUP_REPLICATION; <br /> Query OK, 0 rows affected (3.58 sec) <br /> mysql> SELECT * FROM performance_schema.replication_group_members \G <br /> *************************** 1. row *************************** <br /> CHANNEL_NAME: group_replication_applier <br /> MEMBER_ID: 1ab30239-5ef6-11e9-9b4a-08002712f4b1 <br /> MEMBER_HOST: centosa <br /> MEMBER_PORT: 3306 <br /> MEMBER_STATE: ONLINE <br /> MEMBER_ROLE: PRIMARY <br /> MEMBER_VERSION: 8.0.15 <br /> <br /> *************************** 2. row *************************** <br /> CHANNEL_NAME: group_replication_applier <br /> MEMBER_ID: 572ca2fa-5eff-11e9-8df9-08002712f4b1 <br /> MEMBER_HOST: centosb <br /> MEMBER_PORT: 3306 <br /> MEMBER_STATE: ONLINE <br /> MEMBER_ROLE: SECONDARY <br /> MEMBER_VERSION: 8.0.15 <br /> <br /> *************************** 3. row *************************** <br /> CHANNEL_NAME: group_replication_applier <br /> MEMBER_ID: c5f3d1d2-8dd8-11e9-858d-08002773d1b6 <br /> MEMBER_HOST: centosc <br /> MEMBER_PORT: 3306 <br /> MEMBER_STATE: ONLINE <br /> MEMBER_ROLE: SECONDARY <br /> MEMBER_VERSION: 8.0.15 <br /> 3 rows in set (0.00 sec) </code> </div>
<br /><br /> <span class="notranslate">所以這一切都很棒,但並不總是意味著他們上網,他們通常可以坐在恢復模式。</span> <br /> <span class="notranslate">到目前為止,我已經看到MySQL崩潰失敗,所以需要確保它穩定。</span> <br /><div class="codebox">
<code>mysql>
create database testcentosb;<br> ERROR 1290 (HY000): The MySQL
server is running with the --super-read-only option so it cannot execute
this statement<br></code> </div>
<span class="notranslate">附註解決其中一些因素 - </span> <br /><div class="codebox">
<code>mysql> START GROUP_REPLICATION; <br /> ERROR 3094 (HY000): The START GROUP_REPLICATION command failed as the applier module failed to start. <br /> <br /> mysql> reset slave all; <br /> Query OK, 0 rows affected (0.03 sec) <br /> </code> </div>
<span class="notranslate"> - 然後從Change master命令重新開始</span> <br /><div class="codebox">
<code>mysql> START GROUP_REPLICATION; <br />
ERROR 3092 (HY000): The server is not configured properly to be an
active member of the group. Please see more details on error log. <br /> <br />
[ERROR] [MY-011735] [Repl] Plugin group_replication reported: '[GCS]
Error on opening a connection to 192.168.111.17:33061 on local port:
33061.' <br /> [ERROR] [MY-011526] [Repl] Plugin group_replication
reported: 'This member has more executed transactions than those present
in the group. Local transactions:
c5f3d1d2-8dd8-11e9-858d-08002773d1b6:1-4 > <br /> [ERROR] [MY-011522]
[Repl] Plugin group_replication reported: 'The member contains
transactions not present in the group. The member will now exit the
group.' </code> </div>
<br /> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=https://ronniethedba.wordpress.com/2017/04/22/this-member-has-more-executed-transactions-than-those-present-in-the-group/&xid=17259,15700021,15700186,15700191,15700256,15700259&usg=ALkJrhhX7pPnpk3RnXdHfHpk9vKRyksYvg" target="_blank">https://ronniethedba.wordpress.com/2017/04/22/this-member-has-more-executed-transactions-than-those-present-in-the-group/</a></span> </div>
<br /><br />
<div class="codebox">
<code>[ERROR]
[MY-011620] [Repl] Plugin group_replication reported: 'Fatal error
during the recovery process of Group Replication. The server will leave
the group.' <br /> [ERROR] [MY-013173] [Repl] Plugin group_replication
reported: 'The plugin encountered a critical error and will abort: Fatal
error during execution of Group Replication' <br /> <br /> SELECT * FROM performance_schema.replication_connection_status\G</code> </div>
<br /><br /> <span class="notranslate">我的想法...</span> <br /> <span class="notranslate">請記住,可以在單主模式或多節點中設置組複製</span> <br />
<div class="codebox">
<code>mysql> select @@group_replication_single_primary_mode\G <br /> *************************** 1. row *************************** <br /> @@group_replication_single_primary_mode: 1 <br /> <br /> mysql> create database testcentosb; <br /> ERROR 1290 (HY000): The MySQL server is running with the --super-read-only option so it cannot execute this statement </code> </div>
<span class="notranslate">如果您寫入無主節點,您當然會收到錯誤。</span> <br />
<div class="codebox">
<div class="p1">
<span class="s1"><br /></span> </div>
<br /><div class="p1">
<span class="notranslate"> <span class="s1">group-replication-single-primary-mode = off < - 添加到cnf文件中。</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">mysql> SELECT * FROM performance_schema.replication_group_members;</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">+
--------------------------- + --------------------- ----------------- +
------------- ------------- + + ---- ---------- + ------------- +
---------------- +</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">|</span></span> <span class="notranslate"> <span class="s1">CHANNEL_NAME</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">|</span></span> <span class="notranslate"> <span class="s1">會員ID</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">|</span></span> <span class="notranslate"> <span class="s1">MEMBER_HOST |</span></span> <span class="notranslate"> <span class="s1">MEMBER_PORT |</span></span> <span class="notranslate"> <span class="s1">MEMBER_STATE |</span></span> <span class="notranslate"> <span class="s1">MEMBER_ROLE |</span></span> <span class="notranslate"> <span class="s1">MEMBER_VERSION |</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">+
--------------------------- + --------------------- ----------------- +
------------- ------------- + + ---- ---------- + ------------- +
---------------- +</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">|</span></span> <span class="notranslate"> <span class="s1">group_replication_applier |</span></span> <span class="notranslate"> <span class="s1">1ab30239-5ef6-11e9-9b4a-08002712f4b1 |</span></span> <span class="notranslate"> <span class="s1">centosa</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">|</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">3306 |</span></span> <span class="notranslate"> <span class="s1">RECOVERING</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">|</span></span> <span class="notranslate"> <span class="s1">主</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">|</span></span> <span class="notranslate"> <span class="s1">8.0.15</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">|</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">|</span></span> <span class="notranslate"> <span class="s1">group_replication_applier |</span></span> <span class="notranslate"> <span class="s1">572ca2fa-5eff-11e9-8df9-08002712f4b1 |</span></span> <span class="notranslate"> <span class="s1">centosb</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">|</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">3306 |</span></span> <span class="notranslate"> <span class="s1">線上</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">|</span></span> <span class="notranslate"> <span class="s1">主</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">|</span></span> <span class="notranslate"> <span class="s1">8.0.15</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">|</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">|</span></span> <span class="notranslate"> <span class="s1">group_replication_applier |</span></span> <span class="notranslate"> <span class="s1">c5f3d1d2-8dd8-11e9-858d-08002773d1b6 |</span></span> <span class="notranslate"> <span class="s1">centosc</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">|</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">3306 |</span></span> <span class="notranslate"> <span class="s1">RECOVERING</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">|</span></span> <span class="notranslate"> <span class="s1">主</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">|</span></span> <span class="notranslate"> <span class="s1">8.0.15</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">|</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">+
--------------------------- + --------------------- ----------------- +
------------- ------------- + + ---- ---------- + ------------- +
---------------- +</span></span> </div>
<br /><div class="p1">
<span class="notranslate"> <span class="s1">3組(0.00秒)</span></span> </div>
</div>
<br /><br /> <span class="notranslate">現在,如果您使用Keepalived,MySQL路由器,ProxySQL等來處理您的流量,以便在發生故障轉移時自動翻轉。</span> <span class="notranslate">當我停止主要時,我們可以從下面看到它立即失敗了。</span> <br /><br />
<div class="codebox">
<code>mysql> SELECT * FROM performance_schema.replication_group_members ; <br />
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
<br /> | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION | <br />
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
<br /> | group_replication_applier | 1ab30239-5ef6-11e9-9b4a-08002712f4b1 | centosa | 3306 | ONLINE | PRIMARY | 8.0.15 | <br /> | group_replication_applier | 572ca2fa-5eff-11e9-8df9-08002712f4b1 | centosb | 3306 | ONLINE | SECONDARY | 8.0.15 | <br /> | group_replication_applier | c5f3d1d2-8dd8-11e9-858d-08002773d1b6 | centosc | 3306 | ONLINE | SECONDARY | 8.0.15 | <br />
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
<br /> 3 rows in set (0.00 sec) <br /> <br /> [root@centosa]# systemctl stop mysqld <br /> <br /> mysql> SELECT * FROM performance_schema.replication_group_members ; <br />
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
<br /> | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION | <br />
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
<br /> | group_replication_applier | 572ca2fa-5eff-11e9-8df9-08002712f4b1 | centosb | 3306 | ONLINE | PRIMARY | 8.0.15 | <br /> | group_replication_applier | c5f3d1d2-8dd8-11e9-858d-08002773d1b6 | centosc | 3306 | ONLINE | SECONDARY | 8.0.15 | <br />
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
<br /> 2 rows in set (0.00 sec) <br /> <br /> [root@centosa]# systemctl start mysqld <br /> [root@centosa]# mysql <br /> mysql> START GROUP_REPLICATION; <br /> Query OK, 0 rows affected (3.34 sec) <br /> <br /> mysql> SELECT * FROM performance_schema.replication_group_members ; <br />
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
<br /> | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION | <br />
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
<br /> | group_replication_applier | 1ab30239-5ef6-11e9-9b4a-08002712f4b1 | centosa | 3306 | RECOVERING | SECONDARY | 8.0.15 | <br /> | group_replication_applier | 572ca2fa-5eff-11e9-8df9-08002712f4b1 | centosb | 3306 | ONLINE | PRIMARY | 8.0.15 | <br /> | group_replication_applier | c5f3d1d2-8dd8-11e9-858d-08002773d1b6 | centosc | 3306 | ONLINE | SECONDARY | 8.0.15 | <br />
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
<br /> 3 rows in set (0.00 sec) </code> </div>
<br /><br /> <span class="notranslate">現在復蘇仍然是一個問題,因為它不會簡單地加入。</span> <span class="notranslate">不得不再次審查所有帳戶和步驟,但我最終確實得到了它。</span> <br /><br />
<div class="codebox">
<code>mysql> SELECT * FROM performance_schema.replication_group_members; <br />
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
<br /> | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION | <br />
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
<br /> | group_replication_applier | 1ab30239-5ef6-11e9-9b4a-08002712f4b1 | centosa | 3306 | ONLINE | SECONDARY | 8.0.15 | <br /> | group_replication_applier | 572ca2fa-5eff-11e9-8df9-08002712f4b1 | centosb | 3306 | ONLINE | PRIMARY | 8.0.15 | <br /> | group_replication_applier | c5f3d1d2-8dd8-11e9-858d-08002773d1b6 | centosc | 3306 | ONLINE | SECONDARY | 8.0.15 | <br />
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
<br /> 3 rows in set (0.00 sec) </code> </div>
<br /><br /> <span class="notranslate">我需要對此進行更多測試,因為我還沒有100%銷售,因為我仍然傾向於Galera複製。</span> <br /><br /> <span class="notranslate">感興趣的URL</span> <br /><br /><br />
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/8.0/en/group-replication.html&xid=17259,15700021,15700186,15700191,15700256,15700259&usg=ALkJrhhOkaKJYw5H5g_Ikz6OCtSTw0ibXQ">https://dev.mysql.com/doc/refman/8.0/en/group-replication.html</a></span> </li>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/8.0/en/group-replication-deploying-in-single-primary-mode.html&xid=17259,15700021,15700186,15700191,15700256,15700259&usg=ALkJrhgxwQ09gtIDRyGAaD9x96Qf2LxJ9g">https://dev.mysql.com/doc/refman/8.0/en/group-replication-deploying-in-single-primary-mode.html</a></span> </li>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=http://datacharmer.blogspot.com/2017/01/mysql-group-replication-vs-multi-source.html&xid=17259,15700021,15700186,15700191,15700256,15700259&usg=ALkJrhi67ErNaaw1FI5kaf6NtYs0voA6Mw">http://datacharmer.blogspot.com/2017/01/mysql-group-replication-vs-multi-source.html</a></span> </li>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/8.0/en/group-replication-launching.html&xid=17259,15700021,15700186,15700191,15700256,15700259&usg=ALkJrhizNxMzcsqT9lbqP6LfWBf7808qfA">https://dev.mysql.com/doc/refman/8.0/en/group-replication-launching.html</a></span> </li>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/8.0/en/group-replication-configuring-instances.html&xid=17259,15700021,15700186,15700191,15700256,15700259&usg=ALkJrhhYkCrNurysHGzw6kB72F3HEig9ww">https://dev.mysql.com/doc/refman/8.0/en/group-replication-configuring-instances.html</a></span> </li>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/8.0/en/group-replication-adding-instances.html&xid=17259,15700021,15700186,15700191,15700256,15700259&usg=ALkJrhggsN6Hu069AUqouvF6PMPGC8ATVg">https://dev.mysql.com/doc/refman/8.0/en/group-replication-adding-instances.html</a></span> </li>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=https://ronniethedba.wordpress.com/2017/04/22/how-to-setup-mysql-group-replication/&xid=17259,15700021,15700186,15700191,15700256,15700259&usg=ALkJrhhyvPZOBHKwl3B85_WcPHa3l9wWrg">https://ronniethedba.wordpress.com/2017/04/22/how-to-setup-mysql-group-replication/</a></span> </li>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=https://www.digitalocean.com/community/tutorials/how-to-configure-mysql-group-replication-on-ubuntu-16-04&xid=17259,15700021,15700186,15700191,15700256,15700259&usg=ALkJrhhu5PhmJM1iLDrdzaW8vm8GWlHSbw">https://www.digitalocean.com/community/tutorials/how-to-configure-mysql-group-replication-on-ubuntu-16-04</a></span> </li>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/8.0/en/group-replication-options.html&xid=17259,15700021,15700186,15700191,15700256,15700259&usg=ALkJrhh0ovas3PIpDm5TpcNPFoRPe3QFdA#sysvar_group_replication_group_seeds">https://dev.mysql.com/doc/refman/8.0/en/group-replication-options.html#sysvar_group_replication_group_seeds</a></span> </li>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=https://bugs.mysql.com/bug.php%3Fid%3D90534&xid=17259,15700021,15700186,15700191,15700256,15700259&usg=ALkJrhgkwta7DyNVT9AhodCxnmiw-Wz8aw" target="_blank">https://bugs.mysql.com/bug.php?id=90534</a></span> </li>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=https://www.percona.com/blog/2017/02/24/battle-for-synchronous-replication-in-mysql-galera-vs-group-replication/&xid=17259,15700021,15700186,15700191,15700256,15700259&usg=ALkJrhgE9YedvsYFZhfCdOSVbisuPN7r6Q">https://www.percona.com/blog/2017/02/24/battle-for-synchronous-replication-in-mysql-galera-vs-group-replication/</a></span> </li>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=https://lefred.be/content/mysql-group-replication-is-sweet-but-can-be-sour-if-you-misunderstand-it/&xid=17259,15700021,15700186,15700191,15700256,15700259&usg=ALkJrhg9giicfmLjq7chcdracBj6-S2wqA">https://lefred.be/content/mysql-group-replication-is-sweet-but-can-be-sour-if-you-misunderstand-it/</a></span> </li>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=https://www.youtube.com/watch%3Fv%3DIfZK-Up03Mw&xid=17259,15700021,15700186,15700191,15700256,15700259&usg=ALkJrhj3sxYL_iEbpT34W_u7jOUUQplVGg">https://www.youtube.com/watch?v=IfZK-Up03Mw</a></span> </li>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=https://mysqlhighavailability.com/mysql-group-replication-a-quick-start-guide/&xid=17259,15700021,15700186,15700191,15700256,15700259&usg=ALkJrhipsT3RZSpWx139jg8DvXy7VCLIhg">https://mysqlhighavailability.com/mysql-group-replication-a-quick-start-guide/</a></span></li>
</div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-63557003059387130162019-06-04T02:12:00.001+08:002019-06-04T02:12:25.308+08:00Max_connections 214 4.15.0-46-generic#49-Ubuntu<div dir="ltr" style="text-align: left;" trbidi="on">
<span class="notranslate">因此,max_connections從my.cnf文件中設置的值下降到214的問題在Ubuntu上已經存在了一段時間。</span> <br /><br /> <span class="notranslate">作為一個例子,它在2015年被注意到</span> <br /><br />
<ul>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=https://codepoets.co.uk/2015/mysql-max_connections-stuck-on-214/&xid=17259,15700021,15700186,15700191,15700256,15700259&usg=ALkJrhgZ2t2Q_3JK_dhEvd8YQIxOkdVIBw">https://codepoets.co.uk/2015/mysql-max_connections-stuck-on-214/</a></span> </li>
</ul>
<br /><br /> <span class="notranslate">我最近又碰到了這個,並通過以下步驟解決了。</span> <br /><br /><br />
<div class="codebox">
<code># cp /lib/systemd/system/mysql.service /etc/systemd/system/ <br /> # cd /etc/systemd/system/ <br /> # vi mysql.service <br /> <br /> LimitNOFILE=infinity <br /> LimitMEMLOCK=infinity <br /> <br /> # systemctl daemon-reload <br /> # systemctl restart mysql </code> </div>
<br /><br /> <span class="notranslate">完成這些步驟後,MySQL連接在my.cnf文件中的給定參數處穩定。</span></div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-77990594915369498452019-04-15T06:18:00.001+08:002019-04-15T06:18:59.328+08:00簡單的KeepaliveD設置<div dir="ltr" style="text-align: left;" trbidi="on">
<span class="notranslate">因此,keepalived已經存在了很長一段時間......但是對許多人來說這仍然是一個謎。</span> <br /> <span class="notranslate">所以這是一個非常簡單的例子,說明keepalived如何與MySQL一起工作。</span> <span class="notranslate">希望這可以幫助那些有疑問的人。</span> <br /><br /> <span class="notranslate">我們將有一個簡單的主設備到奴隸設置。</span> <span class="notranslate">意思是..我們寫一個,除非我們故障轉移到第二個事件。</span> <br /><br /> <span class="notranslate"> 1 - 安裝keepalived</span> <br /><br /><br />
<div class="p1">
<span class="notranslate"> <span class="s1">#yum搜索keepalived</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1"><b>keepalived</b> .x86_64:負載均衡器和高可用性服務</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1"><b>僅限</b>名稱和摘要匹配,對所有內容使用“全部搜索”。</span></span> </div>
<div class="p1">
</div>
<div class="p1">
<span class="notranslate"> <span class="s1">#yum -y install keepalived</span></span> </div>
<div class="p1">
<span class="s1"><br /></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1"><span style="font-family: times; font-size: x-small;">你現在應該有一個配置文件</span></span></span> </div>
<div class="p1">
<span class="s1"><span style="font-family: times; font-size: x-small;"><br /></span></span> </div>
<div class="p1">
</div>
<div class="p1">
<span class="notranslate"> <span class="s1">#ls -ltr /etc/keepalived/keepalived.conf</span></span> <span class="s1"> </span> </div>
<div class="p1">
<span class="s1"><br /></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1"><span class="Apple-converted-space"><span style="font-family: times; font-size: x-small;">保留原件,因為你總是備份..右....</span></span></span></span> </div>
<div class="p1">
</div>
<div class="p1">
<span class="notranslate"> <span class="s1">#cp /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.orig</span></span> </div>
<div class="p1">
<span class="s1"><br /></span> </div>
<div class="p1">
<span class="notranslate"> <span style="font-family: "times"; font-size: x-small;">因此,您需要找出可用於虛擬IP的ipaddress。</span></span> <span class="notranslate"> <span style="font-family: "times"; font-size: x-small;">我為這個例子選擇了192.168.0.123。</span></span> </div>
<div class="p1">
<br /></div>
<div class="p1">
<span class="notranslate"> <span style="font-family: "times"; font-size: x-small;">接下來,我們將設置一個腳本用於我們的新配置文件。</span></span> </div>
<div class="p1">
<span style="font-family: "times"; font-size: x-small;"><br /></span> </div>
<div class="p1">
<span class="notranslate"> <span style="font-family: "times"; font-size: x-small;">我在這裡做的一些事情......</span></span> </div>
<div class="p1">
<span class="notranslate"> <span style="font-family: "times"; font-size: x-small;">我在/ etc / keepalived中留下了一個.cnf文件,用於keepalived和一個日誌。</span></span> </div>
<div class="p1">
<span class="notranslate"> <span style="font-family: "times"; font-size: x-small;">這使得示例變得簡單,因此您可以執行此操作或使用您自己的cnf文件。</span></span> </div>
<div class="p1">
<span style="font-family: "times"; font-size: x-small;"><br /></span> </div>
<div class="p1">
<span class="notranslate"> <span style="font-family: "times"; font-size: x-small;">一個腳本:</span></span> <br /> <span style="font-family: "times"; font-size: x-small;"><br /></span> <div class="p1">
<span class="notranslate"> <span class="s1">cat /etc/keepalived/keepalived_check.sh</span></span> <span class="s1"> </span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">#!/斌/慶典</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">#monitor mysql status</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">#如果這個節點mysql死了</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">#並且它的奴隸還活著,然後停止它的keepalived。</span></span> <span class="notranslate"> <span class="s1">另一個節點將綁定IP。</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">export MYSQL_HOME = / etc / keepalived /</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">export PATH = $ MYSQL_HOME / bin:$ PATH</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">的MySQL =“/ USR / bin中/ MySQL的”</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">中mysqladmin =“的/ usr /斌/中mysqladmin”</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">delay_file =“$ MYSQL_HOME / slave_delay_second.log”</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">slave_host = $ 1</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">ALIVE = $($ mysqladmin --defaults-file = $ MYSQL_HOME / .my.localhost.cnf</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">ping |</span></span> <span class="notranslate"> <span class="s1">grep alive |</span></span> <span class="notranslate"> <span class="s1">wc -l);</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">REMOTEALIVE = $($ mysqladmin --defaults-file = $ MYSQL_HOME / .my.remotehost.cnf</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">ping |</span></span> <span class="notranslate"> <span class="s1">grep alive |</span></span> <span class="notranslate"> <span class="s1">wc -l);</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">如果[[$ ALIVE -ne 1]]</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">然後</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">#echo“MySQL已關閉”</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">如果[[$ REMOTEALIVE -eq 1]]</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">然後</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">#</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">迴聲“關機保持活力”</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">systemctl停止keepalived</span></span> <span class="s1"> </span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">#</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">echo“keepalived stop”</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">科幻</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">#其他</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">#echo“MySQL正在上升”</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">#日期</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">科幻</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
</div>
<div class="p1">
<span class="notranslate"> <span class="s1">退出0 #all done</span></span> </div>
</div>
<div class="p1">
<span class="s1"><br /></span> </div>
<div class="p1">
<span class="notranslate"> <span style="font-family: "times"; font-size: x-small;">新的配置文件</span></span> <br /> <span style="font-family: "times"; font-size: x-small;"><br /></span> <div class="p1">
<span class="notranslate"> <span class="s1">cat /etc/keepalived/keepalived.conf</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">global_defs {</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">notification_email {</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">anothermysqldba@gmail.com</span></span> <span class="s1"> </span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">}</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">notification_email_from anothermysqldba@gmail.com</span></span> <span class="s1"> </span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">smtp_server localhost</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">smtp_connect_timeout 30</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">}</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">vrrp_script check_mysql {</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">腳本“/etc/keepalived/keepalived_check.sh”</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">間隔2</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">重量2</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">}</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">vrrp_instance VI_1 {</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">國家MASTER</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">接口enp0s8</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">#<---什麼界面名稱包含您的真實IP / sbin / ifconfig</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">#在ip link show中找到</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">virtual_router_id 51</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">優先級101</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">advert_int 1</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">nopreempt不同</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">#僅在較高優先級節點上需要</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">認證{</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">auth_type PASS</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">auth_pass 1111</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">}</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">track_script {</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">check_mysql</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">}</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">virtual_ipaddress {</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">192.168.0.123</span></span> <span class="s1"> </span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">}</span></span> </div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<br /><div class="p1">
<span class="notranslate"> <span class="s1">}</span></span> </div>
</div>
<div class="p1">
<span class="s1"><br /></span> </div>
<div class="p1">
<span class="s1"><br /></span> </div>
<div class="p1">
<span class="s1"><br /></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1"><span style="font-family: times; font-size: x-small;">這一切都很棒但是有效嗎......</span></span></span> </div>
<div class="p1">
<span class="s1"><span style="font-family: times; font-size: x-small;"><br /></span></span> <span class="notranslate"> <span class="s1"><span style="font-family: times; font-size: x-small;">所以我們有2個主機</span></span></span> <br /> <span class="s1"><span style="font-family: times; font-size: x-small;"><br /></span></span> <div class="p1">
<span class="notranslate"> <span class="s1">[root @ centosa keepalived] #hostname</span></span> </div>
<br /><div class="p1">
<span class="notranslate"> <span class="s1">centosa</span></span> </div>
<div class="p1">
<span class="s1"><br /></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">[root @ centosb keepalived] #hostname</span></span> </div>
<div class="p1">
</div>
<div class="p1">
<span class="notranslate"> <span class="s1">centosb</span></span> </div>
<div class="p1">
<span class="s1"><br /></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1"><span style="font-family: times; font-size: x-small;">啟動keepalived</span></span></span> </div>
<div class="p1">
<br /></div>
<div class="p1">
<span class="notranslate"> <span class="s1">[root @ centosa keepalived] #systemctl status keepalived</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">●keepalived.service - LVS和VRRP高可用性監視器</span></span> </div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">已加載:已加載(/usr/lib/systemd/system/keepalived.service;已禁用;供應商預設:已禁用)</span></span> </div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">活動:不活動(死機)</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">[root @ centosa keepalived] #systemctl restart keepalived</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">[root @ centosa keepalived] #systemctl status keepalived</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s2"><b>●</b></span> <span class="s1">keepalived.service - LVS和VRRP高可用性監視器</span></span> </div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">已加載:已加載(/usr/lib/systemd/system/keepalived.service;已禁用;供應商預設:已禁用)</span></span> </div>
<div class="p1">
</div>
<div class="p2">
<span class="s3"> </span> <span class="notranslate"> <span class="s3">活動:</span> <span class="s1"><b>活動(運行)</b></span></span> </div>
<span class="s1"><span style="font-family: times; font-size: x-small;"><br /></span></span> </div>
<div class="p1">
<div class="p1">
<span class="notranslate"> <span class="s1">[root @ centosa keepalived] #ssh 192.168.0.123'hostname'</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">root@192.168.0.123的密碼:</span></span> <span class="s1"> </span> </div>
<br /><div class="p1">
<span class="notranslate"> <span class="s1">centosa</span></span> </div>
<div class="p1">
<span class="s1"><br /></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1"><span style="font-family: times; font-size: x-small;">證明連接工作已經完成</span></span></span> </div>
<div class="p1">
<span class="s1"><span style="font-family: times; font-size: x-small;"><br /></span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">[root @ centosa keepalived] #mysql --defaults-file = .my.remotehost.cnf --host = 192.168.0.101</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">-e“select @@ hostname”</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">+ ------------ +</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">|</span></span> <span class="notranslate"> <span class="s1">@@ hostname |</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">+ ------------ +</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">|</span></span> <span class="notranslate"> <span class="s1">centosb</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">|</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">+ ------------ +</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">[root @ centosa keepalived] #mysql --defaults-file = .my.remotehost.cnf --host = 192.168.0.102</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">-e“select @@ hostname”</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">+ ------------ +</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">|</span></span> <span class="notranslate"> <span class="s1">@@ hostname |</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">+ ------------ +</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">|</span></span> <span class="notranslate"> <span class="s1">centosa</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">|</span></span> </div>
<div class="p1">
</div>
<div class="p1">
<span class="notranslate"> <span class="s1">+ ------------ +</span></span> </div>
<div class="p1">
<span class="s1"><br /></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1"><span style="font-family: times; font-size: x-small;">仔細檢查它是否正在運行......</span></span></span> </div>
<div class="p1">
<span class="s1"><br /></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">[root @ centosa keepalived] #systemctl status keepalived |</span></span> <span class="notranslate"> <span class="s1">grep活躍</span></span> </div>
<div class="p1">
</div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">活動:</span> <span class="s2"><b>活躍</b></span></span> <span class="s1"> </span></div>
<div class="p1">
<span class="s1"><br /></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">[root @ centosb keepalived] #systemctl status keepalived |</span></span> <span class="notranslate"> <span class="s1">grep活躍</span></span> </div>
<div class="p1">
</div>
<div class="p1">
<span class="s1"> </span> <span class="notranslate"> <span class="s1">活動:</span> <span class="s2"><b>活躍</b></span></span> <span class="s1"> </span></div>
<div class="p1">
<span class="s1"><br /></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1"><span style="font-family: times; font-size: x-small;">測試當前VIP ..停止mysql並觀看相同的VIP更改主機...</span></span></span> </div>
<div class="p1">
<span class="s1"><span style="font-family: times; font-size: x-small;"><br /></span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">[root @ centosa keepalived] #mysql --defaults-file = .my.remotehost.cnf --host = 192.168.0.123</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">-e“select @@ hostname”</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">+ ------------ +</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">|</span></span> <span class="notranslate"> <span class="s1">@@ hostname |</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">+ ------------ +</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">|</span></span> <span class="notranslate"> <span class="s1">centosa</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">|</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">+ ------------ +</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">[root @ centosa keepalived] #systemctl stop mysqld</span></span> <span class="s1"> </span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">[root @ centosa keepalived] #mysql --defaults-file = .my.remotehost.cnf --host = 192.168.0.123</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">-e“select @@ hostname”</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">+ ------------ +</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">|</span></span> <span class="notranslate"> <span class="s1">@@ hostname |</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">+ ------------ +</span></span> </div>
<div class="p1">
<span class="notranslate"> <span class="s1">|</span></span> <span class="notranslate"> <span class="s1">centosb</span></span> <span class="s1"> </span> <span class="notranslate"> <span class="s1">|</span></span> </div>
<div class="p1">
</div>
<div class="p1">
<span class="notranslate"> <span class="s1">+ ------------ +</span></span></div>
</div>
</div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-38633290872514421852019-04-10T04:37:00.001+08:002019-04-10T04:37:51.789+08:00有時慢速數據庫..不是數據庫......<div dir="ltr" style="text-align: left;" trbidi="on">
<span class="notranslate"><span style="background-color: white; color: #455464; font-family: SourceSansPro, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 12px;">所以我最近被要求調查為什麼更新的MySQL 5 .6比舊的5.5慢</span></span> <br /> <span style="background-color: white; color: #455464; font-family: SourceSansPro, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 12px;"><br /></span> <span class="notranslate"> <span style="background-color: white; color: #455464; font-family: SourceSansPro, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 12px;">所以我開始尋找標準變量和緩存等等。</span></span> <br /> <span style="background-color: white; color: #455464; font-family: SourceSansPro, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 12px;"><br /></span> <span class="notranslate"> <span style="background-color: white; color: #455464; font-family: SourceSansPro, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 12px;">測試用例是一個簡單的例程,在5.6上運行的時間比在5.5上運行時長兩倍。</span></span> <br /> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="background-color: white; font-size: 12px;"><br /></span></span> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="background-color: white; font-size: 12px;">添加到混合.. 5.6版本有兩倍Innodb_buffer_pool_size,當然更多ram整體。</span></span></span> <br /> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="background-color: white; font-size: 12px;"><br /></span></span> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="background-color: white; font-size: 12px;">所以我用MySQLslap開始了一些測試......</span></span></span> <br /><br style="background-color: white; box-sizing: border-box; color: #455464; font-family: SourceSansPro, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 12px;" /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">Mysqlslap測試顯示它在5.6上較慢</span></span></span> <br /> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;"><br /></span></span> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">5.6:</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">mysqlslap
--defaults-file =。/。my.cnf --concurrency = 150 --iterations = 130
-query = / test.sql --create-schema = applicationdata --verbose</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">基準</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">運行所有查詢的平均秒數:0.028秒</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">運行所有查詢的最小秒數:0.019秒</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">運行所有查詢的最大秒數:0.071秒</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">運行查詢的客戶端數量:150</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">每個客戶端的平均查詢數:1</span></span></span> <br /> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;"><br /></span></span> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">5.5:</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">mysqlslap
--defaults-file =。/。my.cnf --concurrency = 150 --iterations = 130
--query = / test.sql --create-schema = applicationdata --verbose</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">基準</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">運行所有查詢的平均秒數:0.015秒</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">運行所有查詢的最小秒數:0.011秒</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">運行所有查詢的最大秒數:0.024秒</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">運行查詢的客戶端數量:150</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">每個客戶端的平均查詢數:1</span></span></span> <br /> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;"><br /></span></span> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;"><br /></span></span> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">所有這些都違背了公共基準</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;"><a href="https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-TW&u=http://dimitrik.free.fr/blog/archives/2013/02/mysql-performance-mysql-56-ga-vs-mysql-55-32cores.html%25C2%25A0&xid=17259,15700021,15700186,15700191,15700253,15700256,15700259&usg=ALkJrhhjGTj-r_XK3dV-If4yICy4kHxQlw" target="_blank">http://dimitrik.free.fr/blog/archives/2013/02/mysql-performance-mysql-56-ga-vs-mysql-55-32cores.html</a></span></span></span> <br /> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;"><br /></span></span> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">所以我檢查了磁盤級別 - </span></span></span> <br /> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;"><br /></span></span> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">5.6:</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">#dd if = / dev / zero of = test bs = 1048576 count = 2048</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">2048 + 0條記錄</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">2048 + 0記錄了</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">複製2147483648字節(2.1 GB),25.7401 s,83.4 MB / s</span></span></span> <br /> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;"><br /></span></span> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">#dd if = test of = / dev / null bs = 1048576</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">2048 + 0條記錄</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">2048 + 0記錄了</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">複製2147483648字節(2.1 GB),29.1527 s,73.7 MB / s</span></span></span> <br /> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;"><br /></span></span> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">5.5:</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">#dd if = / dev / zero of = test bs = 1048576 count = 2048</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">2048 + 0條記錄</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">2048 + 0記錄了</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">複製2147483648字節(2.1 GB),19.9214秒,108 MB / s</span></span></span> <br /> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;"><br /></span></span> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">#dd if = test of = / dev / null bs = 1048576</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">2048 + 0條記錄</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">2048 + 0記錄了</span></span></span> <br /> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">複製2147483648字節(2.1 GB),20.0243秒,107 MB / s</span></span></span> <br /> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;"><br /></span></span> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;"><br /></span></span> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;"><br /></span></span> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">無論MySQL如何,5.5的磁盤都比較慢。</span></span></span> <span class="notranslate"> <span style="color: #455464; font-family: SourceSansPro, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 12px;">所以在這種情況下....看看修復磁盤速度.. MySQL運行正常,並將。</span></span></span></div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-81217192017618246762018-05-24T08:07:00.003+08:002018-05-24T08:07:52.127+08:00代理MySQL :: HAproxy || ProxySQL&KeepAlived<div dir="ltr" style="text-align: left;" trbidi="on">
<span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">所以当涉及到路由你的MySQL流量时,存在几个选项。</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br />
<ul style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=http://www.haproxy.org/&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhgvWPDYRij3Ry0VheP4cEGBy98JOA" style="color: #888888; text-decoration-line: none;" target="_blank">HAProxy的</a></span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://mariadb.com/products/technology/maxscale&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhh8Hvxi7Ojl3Ldwn5417rT7MPwgFg" style="color: #888888; text-decoration-line: none;" target="_blank">MariaDB MaxScale</a></span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://www.nginx.com/&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhhhuyX9SKIIjS46gsh6lBs7z2fqYA" style="color: #888888; text-decoration-line: none;" target="_blank">NGINX</a></span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://dev.mysql.com/doc/mysql-router/8.0/en/&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhi85MSr9aKLups3SEWb2Fcfvb71YA" style="color: #888888; text-decoration-line: none;" target="_blank">MySQL路由器</a></span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=http://www.proxysql.com/&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhiWOCV-RuSThxZ_OLrHHwGQ1SFbAQ" style="color: #888888; text-decoration-line: none;" target="_blank">ProxySQL</a></span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate">如果你需要的话,你甚至可以获得<a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://launchpad.net/mysql-proxy&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhixa2kd2k5jEqonSc5EeMP55C5-ng" style="color: #888888; text-decoration-line: none;" target="_blank">MySQL代理</a> ,但它是EOF。</span></li>
</ul>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">现在我已经看到HAproxy更经常地与客户使用,这是非常简单的设置。</span> <span class="notranslate">Percona为那些感兴趣的人提供了一个例子:</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://www.percona.com/doc/percona-xtradb-cluster/LATEST/howtos/haproxy.html&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhhTI2heyFKzZLV7d3j9fARaBqcDbw" style="color: #888888; text-decoration-line: none;">https://www.percona.com/doc/percona-xtradb-cluster/LATEST/howtos/haproxy.html</a></span></li>
</ul>
</div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">我个人喜欢ProxySQL。</span> <span class="notranslate">Percona也很少有这方面的博客</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://github.com/sysown/proxysql/wiki/ProxySQL-Configuration&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhjN3ljhHksd3cIGhvzFeuSkpeuESA" style="color: #888888; text-decoration-line: none;">https://github.com/sysown/proxysql/wiki/ProxySQL-Configuration</a></span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://www.percona.com/blog/2017/01/19/setup-proxysql-for-high-availability-not-single-point-failure/&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhhEg8Uw8NcwRGPx1n5EXC3z5kOsIg" style="color: #888888; text-decoration-line: none;">https://www.percona.com/blog/2017/01/19/setup-proxysql-for-high-availability-not-single-point-failure/</a></span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://www.percona.com/blog/2017/01/25/proxysql-admin-configuration/&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhhGkgDUP2G3BiylB4X-OHrQ1BcDMA" style="color: #888888; text-decoration-line: none;">https://www.percona.com/blog/2017/01/25/proxysql-admin-configuration/</a></span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://www.percona.com/blog/2016/09/15/proxysql-percona-cluster-galera-integration/&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhhROuKqIs_V-cop1tRou2y2jc08OQ" style="color: #888888; text-decoration-line: none;">https://www.percona.com/blog/2016/09/15/proxysql-percona-cluster-galera-integration/</a></span></li>
</ul>
</div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">Percona也有ProxySQL版本可用</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://www.percona.com/downloads/proxysql/&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhg92cpqEpr4xSujyAfrkqBMJhqxgw" style="color: #888888; text-decoration-line: none;">https://www.percona.com/downloads/proxysql/</a></span></li>
</ul>
</div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">我想我会写一些例子,但是整个Percona已经很好地解释了这一点。</span> <span class="notranslate">我不想从这些帖子中拿走任何东西,而是指出通过这些网址可以获得很多好的信息。</span> <span class="notranslate">因此,我不会重写已写入的内容,而会为感兴趣的人创建一组信息。</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">首先比较并决定你自己需要和想要什么。</span> <span class="notranslate">当然,下面的链接会偏向ProxySQL,但它给你一个全面的范围供你考虑。</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=http://www.proxysql.com/compare&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhjb2S9yAWGa2Sc0yPfwtu59MK6GAw" style="color: #888888; text-decoration-line: none;">http://www.proxysql.com/compare</a></span></li>
</ul>
<div>
<span class="notranslate">如果您拥有一个群集或主控要掌握,并且您不关心写vs vs读取到哪个服务器,只要您有连接;</span> <span class="notranslate">那么HAproxy可能是一个简单的快速设置。</span></div>
</div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">ProxySQL的优势在于能够以加权的方式对流量进行分类,简单易行。</span> <span class="notranslate">所以你可以写入节点1,并从节点2和节点3选择拉。有关这方面的文档可以在这里找到:</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://github.com/sysown/proxysql/wiki/ProxySQL-Read-Write-Split-(HOWTO)&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhh8UqVN3kmZ4IjKL-O9HTl6nC4zGQ" style="color: #888888; text-decoration-line: none;">https://github.com/sysown/proxysql/wiki/ProxySQL-Read-Write-Split-(HOWTO)</a></span></li>
</ul>
<div>
<span class="notranslate">是的,它可以通过HAproxy完成,但您必须相应地指导应用程序。</span></div>
<div>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://severalnines.com/resources/tutorials/mysql-load-balancing-haproxy-tutorial&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhjTxJRLwqltHOcKS9DrrasGNsFq2A" style="color: #888888; text-decoration-line: none;">https://severalnines.com/resources/tutorials/mysql-load-balancing-haproxy-tutorial</a></span></li>
</ul>
</div>
<div>
<span class="notranslate">这是根据您的查询规则在ProxySQL中处理的。</span></div>
<div>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://github.com/sysown/proxysql/wiki/Main-(runtime)&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhibK2G93zYzyNq9tSQMsvAyYtMibA#mysql_query_rules" style="color: #888888; text-decoration-line: none;">https://github.com/sysown/proxysql/wiki/Main-(runtime)#mysql_query_rules</a></span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://github.com/sysown/proxysql/wiki/ProxySQL-Configuration&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhjN3ljhHksd3cIGhvzFeuSkpeuESA#mysql-query-rules" style="color: #888888; text-decoration-line: none;">https://github.com/sysown/proxysql/wiki/ProxySQL-Configuration#mysql-query-rules</a></span></li>
</ul>
</div>
<div>
<br /></div>
<div>
<span class="notranslate">现在显而易见的问题是:好的,那么如何让ProxySQL不会成为单点故障?</span></div>
</div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">你可以投资是一个强大的负载平衡器等等等等......抛硬件......或者让自己容易,支持开源并使用<a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=http://www.keepalived.org/&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhgt2sMkFeW73Z34fURT2D1XT6Jhkw" style="color: #888888; text-decoration-line: none;" target="_blank">KeepAlive</a> d。</span> <span class="notranslate">这是非常容易设置,所有这些都记录在这里:</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://www.percona.com/blog/2017/01/19/setup-proxysql-for-high-availability-not-single-point-failure/&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhhEg8Uw8NcwRGPx1n5EXC3z5kOsIg" style="color: #888888; text-decoration-line: none;">https://www.percona.com/blog/2017/01/19/setup-proxysql-for-high-availability-not-single-point-failure/</a></span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=http://www.keepalived.org/doc/&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhhyLqhKxjOS9fAN7FJl1QDmfAf-SA" style="color: #888888; text-decoration-line: none;">http://www.keepalived.org/doc/</a></span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate">公平地说,keepalived和HAproxy也是一个例子</span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://andyleonard.com/2011/02/01/haproxy-and-keepalived-example-configuration/&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhibQ6um4JfnyonpgcRHwLgR5L1lyA" style="color: #888888; text-decoration-line: none;">https://andyleonard.com/2011/02/01/haproxy-and-keepalived-example-configuration/</a></span></li>
</ul>
<div>
<span class="notranslate">如果你曾经处理lua和<a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://anothermysqldba.blogspot.com/2013/05/setup-mysql-proxy.html&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhjkPWop5tAhwmSQhd9jXSuK9KAvwA" style="color: #888888; text-decoration-line: none;" target="_blank">mysql-proxy</a> ,ProxySQL和Keepalived应该对你来说非常简单。</span> <span class="notranslate">如果您仍然希望出于某种原因: <a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://launchpad.net/mysql-proxy&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhixa2kd2k5jEqonSc5EeMP55C5-ng" style="color: #888888; text-decoration-line: none;">https</a> : <a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://launchpad.net/mysql-proxy&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhixa2kd2k5jEqonSc5EeMP55C5-ng" style="color: #888888; text-decoration-line: none;">//launchpad.net/mysql-proxy</a></span></div>
</div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">无论您选择HAproxy,ProxySQL还是其他解决方案,您都需要确保一旦发生单点故障而不会更换另一个故障点,并且keepalived非常适合。</span> <span class="notranslate">如果你正在使用代理,那么没有这么做的理由是没有的。</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">所以ProxySQL上还有更多的东西。</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate">如果您通过报告或监控跟踪连接到数据库的主机,请意识到这些IPS或主机名现在将成为代理服务器。</span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate">那么你已经在MySQL中拥有的所有用户呢?</span> <span class="notranslate">你可以将它们迁移到proxysql吗?</span> <span class="notranslate">是的你可以。</span> <span class="notranslate">它需要几个步骤,但它是可行的。</span> <span class="notranslate">这是一个例子:</span></li>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://dba.stackexchange.com/questions/164705/how-to-easily-bring-80-mysql-users-into-proxysql&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhjuK4Hk7DkUNnRXFbItSlQF3BGoMg" style="color: #888888; text-decoration-line: none;">https://dba.stackexchange.com/questions/164705/how-to-easily-bring-80-mysql-users-into-proxysql</a></span></li>
</ul>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate">确保你了解<a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://github.com/sysown/proxysql/wiki/Configuring-ProxySQL&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhiU0M053XLNb3eFdBbh217ZuWqW6g" style="color: #888888; text-decoration-line: none;" target="_blank">多层配置系统</a> 。</span> <span class="notranslate">将您的信息保存到磁盘!</span></li>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://github.com/sysown/proxysql/wiki/Main-(runtime)&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhibK2G93zYzyNq9tSQMsvAyYtMibA#runtime-tables" style="color: #888888; text-decoration-line: none;">https://github.com/sysown/proxysql/wiki/Main-(runtime)#runtime-tables</a></span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://github.com/sysown/proxysql/wiki/Main-(runtime)&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhibK2G93zYzyNq9tSQMsvAyYtMibA#disk-database" style="color: #888888; text-decoration-line: none;">https://github.com/sysown/proxysql/wiki/Main-(runtime)#disk-database</a></span></li>
</ul>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate">ProxySQL可以在MySQL默认端口3306上运行</span></li>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate">是编辑<a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://github.com/sysown/proxysql/wiki/Global-variables&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhhbhDB6e_6BzwhWo5V-scpUkE6O4Q#mysql-interfaces" style="color: #888888; text-decoration-line: none;" target="_blank">mysql接口</a></span></li>
</ul>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate">现在请记住你的max_connections。</span> <span class="notranslate">如果您将mysql中的Max_connections设置为500,那么对于标准用户来说,这是您的限制。</span> <span class="notranslate">使用ProxySQL,您现在可以将用户分散到系统中并为每个节点设置一个最大值。</span> <span class="notranslate">因此,为了确保您不会遇到500个连接,请将<a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://github.com/sysown/proxysql/wiki/Global-variables&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhhbhDB6e_6BzwhWo5V-scpUkE6O4Q#mysql-max_connections" style="color: #888888; text-decoration-line: none;" target="_blank">mysql-max_connections</a>设置为比MySQL值低一点。</span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate">利用<a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://github.com/sysown/proxysql/wiki/Monitor-Module&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhhI6s-nBwVuxAF0FE-K6euFFtJJLw#monitor-module" style="color: #888888; text-decoration-line: none;" target="_blank">监控模块</a>和<a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://github.com/sysown/proxysql/wiki/STATS-(statistics)&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhjmqdK_hwMDbkslQoffBX_i4xDWiQ#the-stats-database" style="color: #888888; text-decoration-line: none;" target="_blank">STATS</a> 。了解您的代理和流量发生了什么。</span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate">如果适用于您的应用程序,请利用<a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&sp=nmt4&tl=zh-CN&u=https://github.com/sysown/proxysql/wiki/ProxySQL-Configuration&xid=17259,15700022,15700124,15700149,15700168,15700173,15700186,15700189,15700190,15700201,15700205&usg=ALkJrhjN3ljhHksd3cIGhvzFeuSkpeuESA#query-caching" style="color: #888888; text-decoration-line: none;" target="_blank">查询缓存</a> 。</span></li>
</ul>
</div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif;"><span style="font-size: 13.2px;"><a href="http://anothermysqldba.blogspot.com/2018/05/proxy-mysql-haproxy-proxysql-keepalived.html">http://anothermysqldba.blogspot.com/2018/05/proxy-mysql-haproxy-proxysql-keepalived.html</a></span></span></div>
<div style="background-color: white;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif;"><span style="font-size: 13.2px;"><br /></span></span></div>
<div style="background-color: white;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif;"><span style="font-size: 13.2px;"><br /></span></span></div>
</div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-26492214001656299482018-03-20T14:32:00.001+08:002018-03-20T14:32:04.070+08:00MySQL 8.0.4rc<div dir="ltr" style="text-align: left;" trbidi="on">
<span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">MySQL 8.0.4rc剛剛發佈為“ <span style="color: #ee0000; font-family: "open sans", arial, helvetica, sans-serif; font-size: 12.1176px; font-weight: 700; text-align: center;">Pre-General Availability草案:2018-03-19</span> ”。</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br />
<ul style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html&xid=17259,15700022,15700105,15700124,15700149,15700168,15700173,15700186,15700201&usg=ALkJrhiqSG_QMGnpcfygnF5aIGfQ2hdLyA" style="color: #888888; text-decoration-line: none;">https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html</a></span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/relnotes/mysql/8.0/en/&xid=17259,15700022,15700105,15700124,15700149,15700168,15700173,15700186,15700201&usg=ALkJrhg0VyofepMvZ6p1RksvFzazV8LKhQ" style="color: #888888; text-decoration-line: none;">https://dev.mysql.com/doc/relnotes/mysql/8.0/en/</a></span></li>
</ul>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">我決定快速瀏覽並註意我的印象。</span> <span class="notranslate">其中一些對於很多人來說是個舊消息,因為這個版本已經被討論了一段時間,但我仍然加入了我的想法。</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">我注意到的第一件事是使用更新後的mysql客戶端的一個簡單問題。</span> <span class="notranslate">我的舊版本仍然在我的道路上,導致</span></div>
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;"></code><br /><div>
<code style="font-size: 0.9em;">ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded</code></div>
<code style="font-size: 0.9em;"></code></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/8.0/en/caching-sha2-pluggable-authentication.html&xid=17259,15700022,15700105,15700124,15700149,15700168,15700173,15700186,15700201&usg=ALkJrhhty3h9cFz45lp6t8HQnibplSZqBA" style="color: #888888; text-decoration-line: none;">https://dev.mysql.com/doc/refman/8.0/en/caching-sha2-pluggable-authentication.html</a></span></li>
</ul>
</div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">這麼簡單的修復,並確保您使用的是有效的更新MySQL客戶端。</span> <span class="notranslate">當然還有其他選項,例如將認證插件更改回mysql_native_password,但為什麼還要使用安全方法。</span> <span class="notranslate">這是對安全性的非常好的增強,所以如果在使用這種更安全的方法建立連接時遇到一些連接問題,請不要感到震驚。</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;"></code><br /><div>
<div>
<code style="font-size: 0.9em;">Welcome to the MySQL monitor. Commands end with ; or \g.</code></div>
<div>
<code style="font-size: 0.9em;">Your MySQL connection id is 36</code></div>
<div>
<code style="font-size: 0.9em;">Server version: 8.0.4-rc-log</code></div>
<div>
<code style="font-size: 0.9em;"><br /></code></div>
<div>
<code style="font-size: 0.9em;">Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.</code></div>
</div>
<code style="font-size: 0.9em;"></code></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">所以第一個非常酷的增強...</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;"></code><br /><div>
<code style="font-size: 0.9em;">mysql> show create table user\G</code></div>
<code style="font-size: 0.9em;"></code><div>
<code style="font-size: 0.9em;">*************************** 1. row ***************************</code></div>
<div>
<span class="notranslate">表:用戶</span></div>
<div>
<span class="notranslate">創建表:CREATE TABLE`user`(</span></div>
<div>
<span class="notranslate">`主機`字符(60)COLLATE utf8_bin NOT NULL DEFAULT'',</span></div>
<div>
<span class="notranslate">`User` char(32)COLLATE utf8_bin NOT NULL DEFAULT'',</span></div>
<div>
<span class="notranslate">`Select_priv`枚舉('N','Y')字符集utf8不為NULL默認'N',</span></div>
<div>
<span class="notranslate">`Insert_priv` enum('N','Y')字符集utf8不為NULL默認'N',</span></div>
<div>
<span class="notranslate">`Update_priv`枚舉('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Delete_priv` enum('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Create_priv` enum('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Drop_priv`枚舉('N','Y')字符集utf8不為NULL默認'N',</span></div>
<div>
<span class="notranslate">`Reload_priv` enum('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Shutdown_priv`枚舉('N','Y')字符集utf8不為NULL默認'N',</span></div>
<div>
<span class="notranslate">`Process_priv` enum('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`File_priv`枚舉('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Grant_priv`枚舉('N','Y')字符集utf8不為NULL默認'N',</span></div>
<div>
<span class="notranslate">`References_priv`枚舉('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Index_priv` enum('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Alter_priv`枚舉('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Show_db_priv` enum('N','Y')字符集utf8不為NULL默認'N',</span></div>
<div>
<span class="notranslate">`Super_priv` enum('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Create_tmp_table_priv` enum('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Lock_tables_priv` enum('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Execute_priv`枚舉('N','Y')字符集utf8不為NULL默認'N',</span></div>
<div>
<span class="notranslate">`Repl_slave_priv` enum('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Repl_client_priv` enum('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Create_view_priv`枚舉('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Show_view_priv` enum('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Create_routine_priv` enum('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Alter_routine_priv` enum('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Create_user_priv` enum('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Event_priv` enum('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Trigger_priv`枚舉('N','Y')字符集utf8不為NULL默認'N',</span></div>
<div>
<span class="notranslate">`Create_tablespace_priv` enum('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`ssl_type`枚舉('','ANY','X509','SPECIFIED')字符集utf8不為NULL DEFAULT'',</span></div>
<div>
<span class="notranslate">`ssl_cipher` blob NOT NULL,</span></div>
<div>
<span class="notranslate">`x509_issuer` blob NOT NULL,</span></div>
<div>
<span class="notranslate">`x509_subject` blob NOT NULL,</span></div>
<div>
<span class="notranslate">`max_questions` int(11)unsigned NOT NULL DEFAULT'0',</span></div>
<div>
<span class="notranslate">`max_updates` int(11)unsigned NOT NULL DEFAULT'0',</span></div>
<div>
<span class="notranslate">`max_connections` int(11)unsigned NOT NULL DEFAULT'0',</span></div>
<div>
<span class="notranslate">`max_user_connections` int(11)unsigned NOT NULL DEFAULT'0',</span></div>
<div>
<span class="notranslate">`plugin` char(64)COLLATE utf8_bin NOT NULL DEFAULT'caching_sha2_password',</span></div>
<div>
<span class="notranslate">`authentication_string`文本COLLATE utf8_bin,</span></div>
<div>
<span class="notranslate">`password_expired`枚舉('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`password_last_changed` timestamp NULL DEFAULT NULL,</span></div>
<div>
<span class="notranslate">`password_lifetime` smallint(5)unsigned DEFAULT NULL,</span></div>
<div>
<span class="notranslate">`account_locked` enum('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Create_role_priv`枚舉('N','Y')字符集utf8不為NULL默認'N',</span></div>
<div>
<span class="notranslate">`Drop_role_priv` enum('N','Y')字符集utf8不為NULL DEFAULT'N',</span></div>
<div>
<span class="notranslate">`Password_reuse_history` smallint(5)unsigned DEFAULT NULL,</span></div>
<div>
<span class="notranslate">`Password_reuse_time` smallint(5)unsigned DEFAULT NULL,</span></div>
<div>
<span class="notranslate">PRIMARY KEY('Host`,`User`)</span></div>
<div>
<span class="notranslate">)/ *!50100 TABLESPACE`mysql` * / ENGINE = InnoDB DEFAULT CHARSET = utf8 COLLATE = utf8_bin STATS_PERSISTENT = 0 COMMENT ='用戶和全局權限'</span></div>
<div>
<span class="notranslate">一排(0.00秒)</span></div>
</div>
</div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">是的,用戶表是InnoDB並擁有自己的TableSpace。</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">隨著新數據字典的添加,您現在將注意到Information_schema更改。</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/8.0/en/data-dictionary-information-schema.html&xid=17259,15700022,15700105,15700124,15700149,15700168,15700173,15700186,15700201&usg=ALkJrhiabnqCRZsTQ4z6avlQB4Gdd8fqrA" style="color: #888888; text-decoration-line: none;">https://dev.mysql.com/doc/refman/8.0/en/data-dictionary-information-schema.html</a></span></li>
</ul>
<div>
<span class="notranslate">因此,作為一個簡單的示例,歷史上的Columns表格不是一個視圖,但現在已經發生變化,以及許多其他視圖,您可以通過所提供的網址查看。</span></div>
</div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;"></code><br /><div>
<code style="font-size: 0.9em;">mysql> show create table COLUMNS \G</code></div>
<code style="font-size: 0.9em;"></code><div>
<code style="font-size: 0.9em;">*************************** 1. row ***************************</code></div>
<div>
<span class="notranslate">查看:COLUMNS</span></div>
<div>
<span class="notranslate">創建視圖:CREATE ALGORITHM = UNDEFINED DEFINER =`mysql.infoschema` @ localhost`</span></div>
</div>
</div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">這似乎是為了幫助執行information_schema的性能,但是將每個查詢的臨時表創建移除到information_schema中。</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">本文的第14章深入探討了這一點,下面提供的URL將幫助您找到更多信息,未來的博客文章可能會更多地涉及這方面的內容。</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/8.0/en/data-dictionary.html&xid=17259,15700022,15700105,15700124,15700149,15700168,15700173,15700186,15700201&usg=ALkJrhjlGkOxBhGUsg5UguC4zechQfUGig" style="color: #888888; text-decoration-line: none;">https://dev.mysql.com/doc/refman/8.0/en/data-dictionary.html</a></span></li>
</ul>
<div>
<span class="notranslate">前面提到的數據字典也可以導入原子數據定義語言(DDL)語句或原子DDL。</span></div>
</div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/8.0/en/atomic-ddl.html&xid=17259,15700022,15700105,15700124,15700149,15700168,15700173,15700186,15700201&usg=ALkJrhhbllsqXkTu2QwFwRdRCqSFcr7r4Q" style="color: #888888; text-decoration-line: none;">https://dev.mysql.com/doc/refman/8.0/en/atomic-ddl.html</a></span></li>
</ul>
</div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">如果您在設置複製到新的MySQL 8.0實例之前沒有檢查您的查詢,這可能會導致一些事務處理。</span> <span class="notranslate">我說這是因為桌面維護的處理可能會受到影響。</span> <span class="notranslate">如果你用“If Exists”編寫乾淨的查詢,這不會是一個大問題。</span> <span class="notranslate">總的來說,它是一個更基於事務的功能,可以保護您的數據和回滾選項。</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">資源管理看起來非常有趣,我將不得不花更多時間專注於此,因為它是MySQL 8.0的一項新功能。</span> <span class="notranslate">總的來說,您可以分配組,不再需要設置查詢的優先級,而是讓您的分組定義查詢的行為方式以及分配給它的資源。</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/8.0/en/resource-groups.html&xid=17259,15700022,15700105,15700124,15700149,15700168,15700173,15700186,15700201&usg=ALkJrhihCD4YRThyERXFaWXgmy2Q-Md9xg" style="color: #888888; text-decoration-line: none;">https://dev.mysql.com/doc/refman/8.0/en/resource-groups.html</a></span></li>
</ul>
</div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;"></code><br /><div>
<code style="font-size: 0.9em;">mysql> select @@version;</code></div>
<code style="font-size: 0.9em;"></code><div>
<code style="font-size: 0.9em;">+------------+</code></div>
<div>
<span class="notranslate">|</span> <span class="notranslate">@@ version |</span></div>
<div>
<span class="notranslate">+ ------------ +</span></div>
<div>
<span class="notranslate">|</span> <span class="notranslate">5.7.16-log |</span></div>
<div>
<span class="notranslate">+ ------------ +</span></div>
<div>
<span class="notranslate">一排(0.00秒)</span></div>
<div>
<br /></div>
<div>
<span class="notranslate">mysql> desc INFORMATION_SCHEMA.RESOURCE_GROUPS;</span></div>
<div>
<span class="notranslate">錯誤1109(42S02):information_schema中的表“RESOURCE_GROUPS”未知</span></div>
<div>
<br /></div>
<div>
<span class="notranslate">mysql> select @@ version;</span></div>
<div>
<span class="notranslate">+ -------------- +</span></div>
<div>
<span class="notranslate">|</span> <span class="notranslate">@@ version |</span></div>
<div>
<span class="notranslate">+ -------------- +</span></div>
<div>
<span class="notranslate">|</span> <span class="notranslate">8.0.4-rc-log |</span></div>
<div>
<span class="notranslate">+ -------------- +</span></div>
<div>
<span class="notranslate">一排(0.00秒)</span></div>
<div>
<br /></div>
<div>
<span class="notranslate">mysql> desc INFORMATION_SCHEMA.RESOURCE_GROUPS;</span></div>
<div>
<span class="notranslate">+ ------------------------ + ----------------------- + ------ + ----- + --------- + ------- +</span></div>
<div>
<span class="notranslate">|</span> <span class="notranslate">字段|</span> <span class="notranslate">類型|</span> <span class="notranslate">空|</span> <span class="notranslate">Key |</span> <span class="notranslate">默認|</span> <span class="notranslate">額外|</span></div>
<div>
<span class="notranslate">+ ------------------------ + ----------------------- + ------ + ----- + --------- + ------- +</span></div>
<div>
<span class="notranslate">|</span> <span class="notranslate">RESOURCE_GROUP_NAME |</span> <span class="notranslate">varchar(64)|</span> <span class="notranslate">NO |</span> <span class="notranslate">|</span> <span class="notranslate">NULL |</span> <span class="notranslate">|</span></div>
<div>
<span class="notranslate">|</span> <span class="notranslate">RESOURCE_GROUP_TYPE |</span> <span class="notranslate">枚舉('SYSTEM','USER')|</span> <span class="notranslate">NO |</span> <span class="notranslate">|</span> <span class="notranslate">NULL |</span> <span class="notranslate">|</span></div>
<div>
<span class="notranslate">|</span> <span class="notranslate">RESOURCE_GROUP_ENABLED |</span> <span class="notranslate">tinyint(1)|</span> <span class="notranslate">NO |</span> <span class="notranslate">|</span> <span class="notranslate">NULL |</span> <span class="notranslate">|</span></div>
<div>
<span class="notranslate">|</span> <span class="notranslate">VCPU_IDS |</span> <span class="notranslate">blob |</span> <span class="notranslate">是|</span> <span class="notranslate">|</span> <span class="notranslate">NULL |</span> <span class="notranslate">|</span></div>
<div>
<span class="notranslate">|</span> <span class="notranslate">THREAD_PRIORITY |</span> <span class="notranslate">int(11)|</span> <span class="notranslate">NO |</span> <span class="notranslate">|</span> <span class="notranslate">NULL |</span> <span class="notranslate">|</span></div>
<div>
<span class="notranslate">+ ------------------------ + ----------------------- + ------ + ----- + --------- + ------- +</span></div>
<div>
<span class="notranslate">5行(0.00秒)</span></div>
<div>
<br /></div>
</div>
</div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">關於InnoDB緩衝池緩存的更多信息現在可用。</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/8.0/en/innodb-cached-indexes-table.html&xid=17259,15700022,15700105,15700124,15700149,15700168,15700173,15700186,15700201&usg=ALkJrhhsrB3hOqtz-3asp9yCND80mchxHg" style="color: #888888; text-decoration-line: none;">https://dev.mysql.com/doc/refman/8.0/en/innodb-cached-indexes-table.html</a></span></li>
</ul>
</div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;"></code><br /><div>
<code style="font-size: 0.9em;">mysql> desc INFORMATION_SCHEMA.INNODB_CACHED_INDEXES ;</code></div>
<code style="font-size: 0.9em;"></code><div>
<code style="font-size: 0.9em;">+----------------+---------------------+------+-----+---------+-------+</code></div>
<div>
<span class="notranslate">|</span> <span class="notranslate">字段|</span> <span class="notranslate">類型|</span> <span class="notranslate">空|</span> <span class="notranslate">Key |</span> <span class="notranslate">默認|</span> <span class="notranslate">額外|</span></div>
<div>
<span class="notranslate">+ ---------------- + --------------------- + ------ + --- - + --------- + ------- +</span></div>
<div>
<span class="notranslate">|</span> <span class="notranslate">SPACE_ID |</span> <span class="notranslate">int(11)unsigned |</span> <span class="notranslate">NO |</span> <span class="notranslate">|</span> <span class="notranslate">|</span> <span class="notranslate">|</span></div>
<div>
<span class="notranslate">|</span> <span class="notranslate">INDEX_ID |</span> <span class="notranslate">bigint(21)unsigned |</span> <span class="notranslate">NO |</span> <span class="notranslate">|</span> <span class="notranslate">|</span> <span class="notranslate">|</span></div>
<div>
<span class="notranslate">|</span> <span class="notranslate">N_CACHED_PAGES |</span> <span class="notranslate">bigint(21)unsigned |</span> <span class="notranslate">NO |</span> <span class="notranslate">|</span> <span class="notranslate">|</span> <span class="notranslate">|</span></div>
<div>
<span class="notranslate">+ ---------------- + --------------------- + ------ + --- - + --------- + ------- +</span></div>
<div>
<span class="notranslate">3行(0.01秒)</span></div>
</div>
</div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">如果您不確定要設置InnoDB緩衝池,log_sizes或flush方法,MySQL將根據可用內存為您設置這些值。</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<div>
<span class="notranslate">innodb_dedicated_server</span></div>
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;"></code><br /><div>
<code style="font-size: 0.9em;">[mysqld]</code></div>
<code style="font-size: 0.9em;"></code><div>
<code style="font-size: 0.9em;">innodb-dedicated-server=1</code></div>
<div>
<br /></div>
<div>
<span class="notranslate">mysql> select @@ innodb_dedicated_server;</span></div>
<div>
<span class="notranslate">+ --------------------------- +</span></div>
<div>
<span class="notranslate">|</span> <span class="notranslate">@@ innodb_dedicated_server |</span></div>
<div>
<span class="notranslate">+ --------------------------- +</span></div>
<div>
<span class="notranslate">|</span> <span class="notranslate">1 |</span></div>
<div>
<span class="notranslate">+ --------------------------- +</span></div>
</div>
</div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">這個簡單的測試將我的innodb_buffer_pool_size設置為6GB,例如默認值為128MB時。</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/8.0/en/innodb-dedicated-server.html&xid=17259,15700022,15700105,15700124,15700149,15700168,15700173,15700186,15700201&usg=ALkJrhhMCCDU9uPj-K0dGCYBYLDuySs8Kw" style="color: #888888; text-decoration-line: none;">https://dev.mysql.com/doc/refman/8.0/en/innodb-dedicated-server.html</a></span></li>
</ul>
</div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">許多JSON添加以及正則表達式更改。</span> <span class="notranslate">這兩種看起來都很有前途。</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">此版本本身的唯一複制增強功能是現在支持使用緊湊的二進制格式對JSON文檔進行部分更新的二進制日誌記錄。</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">然而,總體而言,許多功能都可用(您可以<a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=http://mysqlhighavailability.com/replication-features-in-mysql-8-0-1/&xid=17259,15700022,15700105,15700124,15700149,15700168,15700173,15700186,15700201&usg=ALkJrhgBFgTifAtxHrWFSkJA020GTlxd8g" style="color: #888888; text-decoration-line: none;" target="_blank">在這裡</a>閱讀所有關於它們的<a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=http://mysqlhighavailability.com/replication-features-in-mysql-8-0-1/&xid=17259,15700022,15700105,15700124,15700149,15700168,15700173,15700186,15700201&usg=ALkJrhgBFgTifAtxHrWFSkJA020GTlxd8g" style="color: #888888; text-decoration-line: none;" target="_blank">信息</a> ),其中一個(我希望我的客戶明天)是每個通道的複製文件管理器。</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/8.0/en/change-replication-filter.html&xid=17259,15700022,15700105,15700124,15700149,15700168,15700173,15700186,15700201&usg=ALkJrhgfakBflSXJI1aqcYirJ3cL2CiSXA" style="color: #888888; text-decoration-line: none;">https://dev.mysql.com/doc/refman/8.0/en/change-replication-filter.html</a></span></li>
</ul>
</div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">我的測試實例已經啟用了二進制日誌,但它們現在默認情況下與基於TABLE和基於文件的主從信息一起使用(默認情況下基於該事務的粉絲)</span></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<span class="notranslate">總的來說,這只是第一眼看到這個版本和對它的非常高層次的想法,還有很多其他的變化。</span> <span class="notranslate">查看有關此版本的其他<a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=https://planet.mysql.com/&xid=17259,15700022,15700105,15700124,15700149,15700168,15700173,15700186,15700201&usg=ALkJrhg60Z3E57uCPZHvSFTX4FwrR3KSHQ" style="color: #888888; text-decoration-line: none;" target="_blank">博客帖子</a>以及<a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/relnotes/mysql/8.0/en/&xid=17259,15700022,15700105,15700124,15700149,15700168,15700173,15700186,15700201&usg=ALkJrhg0VyofepMvZ6p1RksvFzazV8LKhQ" style="color: #888888; text-decoration-line: none;" target="_blank">手冊</a>和<a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/relnotes/mysql/8.0/en/&xid=17259,15700022,15700105,15700124,15700149,15700168,15700173,15700186,15700201&usg=ALkJrhg0VyofepMvZ6p1RksvFzazV8LKhQ" style="color: #888888; text-decoration-line: none;" target="_blank">發行說明</a>也將有所幫助。</span> <span class="notranslate">當然,下載和復審看起來對於管理,安全和復制的觀點非常有希望。</span></div>
<div>
<span class="notranslate"><br /></span></div>
</div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-43400537778889104352018-03-14T07:44:00.001+08:002018-03-14T07:44:09.957+08:00MySQL备忘单<div dir="ltr" style="text-align: left;" trbidi="on">
<span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">因此,我首先发布了,觉得我应该是。</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">我一直非常忙于使用MySQL和所有相关的分支,并且没有按照我的感觉推出博客。</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">所以我会努力。</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">现在,据说我前几天回忆起一个我曾爱过的网站,因为这是一个常见的VI作弊表单。</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">你知道的语法,你知道你需要它,但键入它3次,直到它正确。</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">当它进入正确的时候,你会看到它傻眼,我想我已经写过了。</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">所以我想知道为什么不是一个简单的常见MySQL命令列表,我们每个人都要么每个月键入50次,要么应该知道我们的手背,但忘记了当客户端看着我们的肩膀。</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">对于初学者..</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">我们建立了一个新的MySQL 5.7.6+服务器并登录..</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">在我们可以做任何事情之前需要更改密码。</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">但它是Alter用户未设置通过。</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">我们想知道如何以明文形式阅读密码。</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">改变用户</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br />
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;">ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass'; </code></div>
<span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">设置密码是</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br />
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;">SET PASSWORD FOR 'bob''@'localhost' = PASSWORD('cleartext password'); </code></div>
<br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">清除二进制日志</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br />
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;">PURGE BINARY LOGS TO 'mysql-bin.010';<br />PURGE BINARY LOGS BEFORE '2008-04-02 00:00:00<br />PURGE BINARY LOGS BEFORE NOW() - interval 3 DAY;<br /></code></div>
<br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">MySQL转储</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br />
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;"># COMPACT WILL REMOVE DROP STATEMENTS<br />mysqldump --events --master-data=2 --routines --triggers --compact --all-databases > db.sql<br />mysqldump --events --master-data=2 --routines --triggers --all-databases > NAME.sql<br />mysqldump --opt --routines --triggers dbname > dbname.sql<br />mysqldump --opt --routines --triggers --no-create-info joomla jforms > dataonly.sql </code></div>
<br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">关闭外键一会儿</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br />
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;">SET GLOBAL foreign_key_checks=0; </code></div>
<br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">跳过授予</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br />
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;">/usr/bin/mysqld_safe --defaults-file=/etc/mysql/my.cnf --skip-grant-tables<br />vi /etc/mysql/my.cnf<br />[mysqld]<br />skip-grant-tables<br /></code></div>
<br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">BinLog评论</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">--base64-output = DECODE-ROWS&--verbose</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br />
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;">mysqlbinlog --defaults-file=/home/anothermysqldba/.my.cnf --base64-output=DECODE-ROWS --verbose binlog.005862 > 005862.sql<br /></code></div>
<br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">MYSQL SECURE客户端</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br />
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;">mysql_config_editor print --all<br />mysql_config_editor set --user=mysql --password --login-path=localhost --host=localhost<br />mysql --login-path=localhost -e 'SELECT NOW()';<br /></code></div>
<br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">交换</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br />
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;">sudo swapoff -a<br />To set the new value to 10: echo 10 | sudo tee /proc/sys/vm/swappiness<br />sudo swapon -a </code></div>
<br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">如果信息模式缓慢</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br />
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;">set global innodb_stats_on_metadata=0; </code></div>
<br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">AWS变量</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br />
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;">CALL mysql.rds_show_configuration;<br />> call mysql.rds_set_configuration('binlog retention hours', 24);<br />> call mysql.rds_set_configuration('slow_launch_time', 2);<br /></code></div>
<br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">查找列名称所在的表</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br />
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;">SELECT TABLE_SCHEMA , TABLE_NAME , COLUMN_NAME FROM information_schema.COLUMNS WHERE COLUMN_NAME = 'fieldname' ; </code></div>
<span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">客户说它在TableA中,但他们有50个数据库。什么模式有TableA</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br />
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;">SELECT TABLE_SCHEMA , TABLE_NAME FROM information_schema.TABLES WHERE TABLE_NAME = 'TableA' ; </code></div>
<br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">调整奴隶工</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br />
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;">Select @@slave_parallel_workers;<br />Stop Slave; Set GLOBAL slave_parallel_workers=5; Start Slave;<br /></code></div>
<br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">MySQL多</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br />
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;">5.6><br />To start both : mysqld_multi start 1,2<br />To check on status of both: mysqld_multi report 1,2<br />To check on status or other options you can use just one<br /><br />5.7<<br />[mysqld1] BECOMES [mysqld@mysqld1]<br />systemctl start mysqld@mysqld1<br />systemctl start mysqld@mysqld2<br />systemctl start mysqld@mysqld3<br />systemctl start mysqld@mysqld4 </code></div>
<span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">仅限MySQL升级系统表</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br />
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;">mysql_upgrade --defaults-file=/home/ <span style="background-color: white;">anothermysqldba</span> /.my.cnf --upgrade-system-tables </code></div>
<br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">SKIP REPLICATION ERROR</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br />
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;">STOP SLAVE; SET GLOBAL sql_slave_skip_counter =1; START SLAVE; SELECT SLEEP(1); SHOW SLAVE STATUS\G </code></div>
</div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-7483433127598394122017-10-14T07:47:00.001+08:002017-10-14T07:47:39.731+08:00MySQL InnoDB表空間加密<div dir="ltr" style="text-align: left;" trbidi="on">
<span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">MySQL表空間加密設置相對簡單。</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">你必須使用MySQL 5.7,innodb_file_per_table</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br />
<ul style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/5.7/en/innodb-tablespace-encryption.html&usg=ALkJrhjKD9_L23Oktn9kr8uIA8-wU24xuw" style="color: #888888; text-decoration-line: none;">https://dev.mysql.com/doc/refman/5.7/en/innodb-tablespace-encryption.html</a></span></li>
</ul>
<br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">MySQL文檔涵蓋了您需要設置的所有內容:</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br />
<ul style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px; line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=https://dev.mysql.com/doc/refman/5.7/en/keyring.html&usg=ALkJrhiV-aNWJUHxyaqdbIOC0RWzaYDc9A" style="color: #888888; text-decoration-line: none;">https://dev.mysql.com/doc/refman/5.7/en/keyring.html</a></span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=https://www.percona.com/blog/2016/04/08/mysql-data-at-rest-encryption&usg=ALkJrhg563zo4wixPL3t6xXlwRZ_NIn25g" style="color: #888888; text-decoration-line: none;">https://www.percona.com/blog/2016/04/08/mysql-data-at-rest-encryption</a></span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-TW&u=http://mysqlserverteam.com/mysql-enterprise-transparent-data-encryption-tde-provides-at-rest-encryption-for-physical-innodb-tablespace-data-files/&usg=ALkJrhjUByU57qwSsAst71UM5fRHS8Hj5A" style="color: #888888; text-decoration-line: none;">http://mysqlserverteam.com/mysql-enterprise-transparent-data-encryption-tde-provides-at-rest-encryption-for-physical-innodb-tablespace-data-files/</a></span></li>
</ul>
<br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">但是如果我剛剛分享了一個鏈接,我的博文將很短。</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">所以....</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">升級後,在MySQL 5.7中,您需要有一個有效的密鑰文件位置。</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">我有一個MySQL datadir作為/ var / lib / mysql / data這允許默認的位置為人們找到它,如果需要,但也允許一個簡單的安裝位置為更多的磁盤,如果需要,以及。</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">這也避免了對selinux等進行其他編輯,因為它已經允許/ var / lib / mysql。</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">觸摸/ var / lib / mysql / keyring</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">chmod 750 / var / lib / mysql / keyring *</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">chown mysql:mysql / var / lib / mysql / keyring</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">編輯mysql .cnf文件:</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">ls /usr/lib64/mysql/plugin/keyring_file.so</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">/usr/lib64/mysql/plugin/keyring_file.so</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">的[mysqld]</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">#鍵盤插件安裝</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">早期插件負荷= keyring_file.so</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">keyring_file_data =的/ var / lib中/ MySQL的/鑰匙圈</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">MySQL啟動後檢查您的插件:</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">mysql> SELECT PLUGIN_NAME,PLUGIN_STATUS</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">- > FROM INFORMATION_SCHEMA.PLUGINS</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">- > WHERE PLUGIN_NAME LIKE'keyring%';</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">+ -------------- + --------------- +</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">|</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">PLUGIN_NAME |</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">PLUGIN_STATUS |</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">+ -------------- + --------------- +</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">|</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">keyring_file |</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">ACTIVE |</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">|</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">keyring_udf |</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">ACTIVE |</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">+ -------------- + --------------- +</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br />
<div style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">
<br /></div>
<br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">INSTALL PLUGIN keyring_udf SONAME'keyring_udf.so';</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">CREATE FUNCTION keyring_key_generate RETURNS INTEGER SONAME'keyring_udf.so';</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">CREATE FUNCTION keyring_key_fetch RETURNS STRING SONAME'keyring_udf.so';</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">CREATE FUNCTION keyring_key_length_fetch RETURNS INTEGER SONAME'keyring_udf.so';</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">CREATE FUNCTION keyring_key_type_fetch RETURNS STRING SONAME'keyring_udf.so';</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">CREATE FUNCTION keyring_key_store RETURNS INTEGER SONAME'keyring_udf.so';</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">CREATE FUNCTION keyring_key_remove RETURNS INTEGER SONAME'keyring_udf.so';</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">mysql>使用測試;</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">mysql> SELECT keyring_key_generate('MyKey1','AES',32);</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">mysql> CREATE TABLE`enc_test`(</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">`enc_test_id` varchar(255)NOT NULL,</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">PRIMARY KEY(`enc_test_id`)</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">)ENGINE = InnoDB;</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">mysql> alter table test.enc_test encryption ='Y';</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">mysql> show create table enc_test \ G</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">*************************** 1.行******************** *******</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">表:enc_test</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">創建表:CREATE TABLE`enc_test`(</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">`enc_test_id` varchar(255)NOT NULL,</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">PRIMARY KEY(`enc_test_id`)</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">)ENGINE = InnoDB DEFAULT CHARSET = latin1 <b>ENCRYPTION ='Y'</b></span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span><br style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;" /><span class="notranslate" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;">1排(0.00秒)</span><span style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, Verdana, sans-serif; font-size: 13.2px;"> </span></div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-29555595795608598932016-04-22T23:02:00.000+08:002016-04-22T23:02:35.825+08:00數學與MySQL<div dir="ltr" style="text-align: left;" trbidi="on">
The Original post: <a href="http://anothermysqldba.blogspot.com/2016/04/math-with-mysql.html">http://anothermysqldba.blogspot.com/2016/04/math-with-mysql.html</a><br />
<br />
<span class="notranslate">我以為我張貼了這個很久以前...哦....</span> <br /><br /> <span class="notranslate">我們都知道,數學是所有生命的基本方面,如果沒有超越世界各地使用的通用語言。</span> <span class="notranslate"> MySQL的,像所有的數據庫,可以幫助您與數學的許多方面。</span> <br /><br /> <span class="notranslate">下面是功能列表: <a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=en&tl=zh-TW&u=https://dev.mysql.com/doc/refman/5.6/en/mathematical-functions.html&usg=ALkJrhgOpoJs-j6j_A1fyP1WP0gebiQj4w">https://dev.mysql.com/doc/refman/5.6/en/mathematical-functions.html</a></span> <br /><br /> <span class="notranslate">下面是一些簡單的例子,讓你開始。</span> <br />
<ul style="text-align: left;">
<li> <span class="notranslate">二次公式AX ^ 2 + BX + C = 0</span> </li>
</ul>
<div class="codebox">
<code><br /> # 2x^2 – 4x – 3 = 0. <br /> SET @a= 1; <br /> SET @b= 3; <br /> SET @c= -4; <br /> SET @XX = ( -(@b) - SQRT( POW(@b,2) -4 * @a * @c) / POW(@a,2) ) ; <br /> SET @YY = ( -(@b) + SQRT( POW(@b,2) -4 * @a * @c) / POW(@a,2) ) ; <br /> SET @XXX = MOD(@YY, @XX); <br /> <br /> SELECT @XX / @XXX as X; <br /> +------+ <br /> | X | <br /> +------+ <br /> | -4 | <br /> +------+ <br /> SELECT @YY / @XXX as X ; <br /> +------+ <br /> | X | <br /> +------+ <br /> | 1 | <br /> +------+ <br /> </code> </div>
<br /><ul style="text-align: left;">
<li> <span class="notranslate">勾股定理(記住幾何101):A ^ 2 + B ^ 2 = C ^ 2</span> </li>
</ul>
<div class="codebox">
<code><br /> SET @A = 14; <br /> SET @B = 48; <br /> SELECT @C := SQRT(POW(@A,2) + POW(@B,2) ); <br /> +-------------------------------------+ <br /> | @C := SQRT(POW(@A,2) + POW(@B,2) ) | <br /> +-------------------------------------+ <br /> | 50 | <br /> +-------------------------------------+ </code> </div>
<br /><br /> <span class="notranslate">這樣解決了C和你當然使用這個求解的為好。</span> <br /><div class="codebox">
<code><br /> SELECT @A := SQRT(POW(@C,2) - POW(@B,2)) ; <br /> +-----------------------------------+ <br /> | @A := SQRT(POW(@C,2) - POW(@B,2)) | <br /> +-----------------------------------+ <br /> | 14 | <br /> +-----------------------------------+ </code> </div>
<br /><br /><ul style="text-align: left;">
<li> <span class="notranslate">對數和它的身份登錄XY =日誌X +記錄Y</span> </li>
</ul>
<a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=en&tl=zh-TW&u=http://www.businessinsider.com/the-17-equations-that-changed-the-world-2012-7&usg=ALkJrhheM_rBYd1e91gBjEAGGKIAQl6m6Q#the-logarithm-and-its-identities-2">http://www.businessinsider.com/the-17-equations-that-changed-the-world-2012-7#the-logarithm-and-its-identities-2</a> <br /><br /><div class="codebox">
<code><br /> SET @X = 2; <br /> SET @Y = 3; <br /> SELECT concat(log(@X * @Y) ,' = ', log(@X) + log(@Y) ) as "logarithm and its identities" ; <br /> +---------------------------------------+ <br /> | logarithm and its identities | <br /> +---------------------------------------+ <br /> | 1.791759469228055 = 1.791759469228055 | <br /> +---------------------------------------+ </code> </div>
<br /><ul style="text-align: left;">
<li> <span class="notranslate">歐拉公式為多面體:F - E + V = 2</span> </li>
</ul>
<a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=en&tl=zh-TW&u=http://www.businessinsider.com/the-17-equations-that-changed-the-world-2012-7&usg=ALkJrhheM_rBYd1e91gBjEAGGKIAQl6m6Q#eulers-formula-for-polyhedra-6">http://www.businessinsider.com/the-17-equations-that-changed-the-world-2012-7#eulers-formula-for-polyhedra-6</a> <br /><div class="codebox">
<code><br /> SET @V = 4; # Vertices <br /> SET @E = 6; # Edges <br /> SET @F = 4; # Faces <br /> SELECT @V - @E + @F as Tetrahedron; <br /> <br /> SET @V = 8; # Vertices <br /> SET @E = 12; # Edges <br /> SET @F = 6; # Faces <br /> SELECT @V - @E + @F as Hexahedron; <br /> <br /> SET @V = 12; # Vertices <br /> SET @E = 30; # Edges <br /> SET @F = 20; # Faces <br /> SELECT @V - @E + @F as Icosahedron; <br /> <br /> SET @V = 12; # Vertices <br /> SET @E = 30; # Edges <br /> SET @F = 20; # Faces <br /> SELECT @V - @E + @F as Icosahedron; </code> </div>
<br /><ul style="text-align: left;">
<li> <span class="notranslate">相對論電子商務愛因斯坦的相對論= mc ^ 2</span> </li>
</ul>
<div class="codebox">
<code><br /> SET @lbs = 190; # lbs <br /> SET @lb2gram = 453.6; # 1 lbs = 453.6g <br /> SET @lbstograms := @lbs * @lb2gram / 1; <br /> SET @m := @lbstograms * 1 / 1000; <br /> SET @c := POW(3.00 * POW(10,8), 2 ); <br /> SELECT @E := @m * @c ; <br /> +----------------+ <br /> | @E := @m * @c | <br /> +----------------+ <br /> | 7.75656e18 | <br /> +----------------+ </code> </div>
<br /><ul style="text-align: left;">
<li> <span class="notranslate"> 1 = 0.9999 .....</span> </li>
</ul>
<div class="codebox">
<code><br /> SELECT SUM(.9/(9/10)); <br /> +----------------+ <br /> | SUM(.9/(9/10)) | <br /> +----------------+ <br /> | 1.00000 | <br /> +----------------+ </code> </div>
<br /></div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-51013187153828963472015-07-26T00:17:00.005+08:002015-07-26T00:17:57.987+08:00快速密碼生成與MySQL<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="post-body entry-content" id="post-body-8989280270748377654" itemprop="description articleBody" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.4; orphans: auto; position: relative; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; width: 766px; word-spacing: 0px;">
<div dir="ltr" style="text-align: left;">
<span class="notranslate">Original post <a href="http://anothermysqldba.blogspot.com/2015/07/quick-password-generation-with-mysql.html">http://anothermysqldba.blogspot.com/2015/07/quick-password-generation-with-mysql.html</a></span></div>
<div dir="ltr" style="text-align: left;">
<span class="notranslate"> </span></div>
<div dir="ltr" style="text-align: left;">
<span class="notranslate">這裡是一個快速而簡單的方法來生成使用MySQL密碼的應用程序。</span><span class="Apple-converted-space"> </span><br /><span class="notranslate">該查詢將創建一個大寫和小寫的長度和值隨機生成的密碼。</span><span class="Apple-converted-space"> </span><br /><br /><div class="codebox" style="background-color: #eeeeff; border: 1px solid black; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;"><br />SELECT CONCAT(UCASE(SUBSTRING( SUBSTRING(MD5(RAND()), FLOOR( 1 + (RAND() * 5)) , FLOOR( 8 + (RAND() * 15 )) ) , FLOOR( 1 + (RAND() * 4 )) , FLOOR( 4 + (RAND() * 12 )) )),<span class="Apple-converted-space"> </span><br />SUBSTRING('!@#$%^&*', FLOOR( 1 + (RAND() * 4)) , FLOOR( 1 + (RAND() * 8)) ),<span class="Apple-converted-space"> </span><br />SUBSTRING( SUBSTRING(MD5(RAND()), FLOOR( 1 + (RAND() * 5)) , FLOOR( 8 + (RAND() * 15 )) ) , 5)) as password \G<span class="Apple-converted-space"> </span></code></div>
<br /><br /><span class="notranslate">該查詢將採取隨機值用於動態口令及第一部分上情況下,它在適用時則第二半它增加了一些符號那麼剩下的是在較低的情況下,因為MD5會自動導入。</span><span class="Apple-converted-space"> </span><span class="notranslate">你當然可以調整任何符號,你會喜歡。</span><span class="Apple-converted-space"> </span><br /><br /><span class="notranslate">結果的實施例:</span><span class="Apple-converted-space"> </span><br /><div class="codebox" style="background-color: #eeeeff; border: 1px solid black; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;"><br />CREATE TABLE `generated` (<span class="Apple-converted-space"> </span><br />`password` varchar(255) NOT NULL<span class="Apple-converted-space"> </span><br />) ENGINE=InnoDB ;<span class="Apple-converted-space"> </span><br /><br />MariaDB [(none)]> INSERT INTO test.generated SELECT CONCAT(UCASE(SUBSTRING( SUBSTRING(MD5(RAND()), FLOOR( 1 + (RAND() * 5)) , FLOOR( 8 + (RAND() * 15 )) ) , FLOOR( 1 + (RAND() * 4 )) , FLOOR( 4 + (RAND() * 12 )) )), SUBSTRING('!@#$%^&*', FLOOR( 1 + (RAND() * 4)) , FLOOR( 1 + (RAND() * 8)) ),SUBSTRING( SUBSTRING(MD5(RAND()), FLOOR( 1 + (RAND() * 5)) , FLOOR( 8 + (RAND() * 15 )) ) , 5)) as password;<span class="Apple-converted-space"> </span><br /><br />MariaDB [(none)]> select * from test.generated;<span class="Apple-converted-space"> </span><br />+-----------------------------------+<span class="Apple-converted-space"> </span><br />| password |<span class="Apple-converted-space"> </span><br />+-----------------------------------+<span class="Apple-converted-space"> </span><br />| 7232E1D9$%^&*f7de22c1b14f15c8a6 |<span class="Apple-converted-space"> </span><br />| DEE22B7F7#$%541adcdd1b8e2 |<span class="Apple-converted-space"> </span><br />| 2C4BB81001@#$%^&d0d9a2126 |<span class="Apple-converted-space"> </span><br />| 941D3B92D@#$%^a4b7be92 |<span class="Apple-converted-space"> </span><br />| 1CF2563254FC@#a79bb5 |<span class="Apple-converted-space"> </span><br />| 2AE86E7D6!@#$%^&*4ca03f2e8 |<span class="Apple-converted-space"> </span><br />| 074DD8D3#$e70a1 |<span class="Apple-converted-space"> </span><br />| B2DDC!@#$%^47a252f79 |<span class="Apple-converted-space"> </span><br />| 3A6D0A#$%^&*01ce9278a2a |<span class="Apple-converted-space"> </span><br />| E9FB4CD16E19!739db9faa1616505c |<span class="Apple-converted-space"> </span><br />| 1ED7A2E1379B4!@#$%ebe60b |<span class="Apple-converted-space"> </span><br />| E9B57D71DB1@#$%^e9a4f8c2e94bf3d35 |<span class="Apple-converted-space"> </span><br />| C97982!@#$8b5c534653c06 |<span class="Apple-converted-space"> </span><br />| DE8998057C8!@#$%^8977a807 |<span class="Apple-converted-space"> </span><br />| 7C7172EB1AE5$%^&*79d2b27 |<span class="Apple-converted-space"> </span><br />| B52CE71@#$%^&*4508 |<span class="Apple-converted-space"> </span><br />| AB17714F!@#$%^&203ba4ff80f8a6 |<span class="Apple-converted-space"> </span><br />| 558D@#$04087871e29ff54 |<span class="Apple-converted-space"> </span><br />| 27A78E8EF#$%^b8cee8628d81593 |<span class="Apple-converted-space"> </span><br />| 315F2EC4#ad9913ec0595c |<span class="Apple-converted-space"> </span><br />+-----------------------------------+</code><span class="Apple-converted-space"> </span><br /><code style="font-size: 0.9em;"><br /></code></div>
</div>
</div>
<div class="post-footer" style="-webkit-text-stroke-width: 0px; background-color: #eeeeee; border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 10.8000001907349px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.6; margin: 20px -2px 0px; orphans: auto; padding: 5px 10px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">
<br class="Apple-interchange-newline" /></div>
</div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-86927650771822343852015-06-29T02:25:00.000+08:002015-06-29T02:25:19.575+08:00斐波那契序列步驟<div dir="ltr" style="text-align: left;" trbidi="on">
<span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">Original post: <a href="http://anothermysqldba.blogspot.com/2015/06/fibonacci-sequence-procedure.html">http://anothermysqldba.blogspot.com/2015/06/fibonacci-sequence-procedure.html</a></span><br />
<span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"> </span><br />
<span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">那麼它已經一段時間,因為我張貼,抱歉。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">今天,我在看電視節目邊緣的重播,當沃爾特引用的斐波那契數列我得到了側履帶與MySQL選項這一點。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">現在這個職位已經存在:</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br />
<ul style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; margin: 0.5em 0px; orphans: auto; padding: 0px 2.5em; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">
<li style="margin: 0px 0px 0.25em; padding: 0px; text-indent: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&tl=zh-TW&u=http://slava-technical.blogspot.com/2010/10/fibonacci-numbers-built-with-sql.html&usg=ALkJrhhGlX4Z8y0M7NF9actQfoib5VcfOw" style="color: #888888; text-decoration: none;">http://slava-technical.blogspot.com/2010/10/fibonacci-numbers-built-with-sql.html</a></span></li>
</ul>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">所以我把這個職位,並擴展了它一點點,結果是,你可以調用和斐波那契數列,你是在後返回範圍的過程。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">該過程如下:</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />delimiter //<span class="Apple-converted-space"> </span><br />CREATE PROCEDURE `Fibonacci`(IN POS INT, IN RANG INT, IN LIMTED INT)<span class="Apple-converted-space"> </span><br />BEGIN<span class="Apple-converted-space"> </span><br />select FORMAT(Fibonacci,0) AS Fibonacci from (<span class="Apple-converted-space"> </span><br />select @f0 Fibonacci, @fn:=@f1+@f0, @f0:=@f1, @f1:=@fn<span class="Apple-converted-space"> </span><br />from (select @f0:=0, @f1:=1, @fn:=1) x,<span class="Apple-converted-space"> </span><br />information_schema.STATISTICS p limit LIMTED) y LIMIT POS, RANG;<span class="Apple-converted-space"> </span><br />END//<span class="Apple-converted-space"> </span><br />delimiter ;<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">您可以致電此並傳遞任何值和範圍後,你是。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">所以,如果你想第5值序列和下一個值(<span class="Apple-converted-space"> </span><i>從0開始</i><span class="Apple-converted-space"> </span>)</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />> CALL Fibonacci(5,2,100);<span class="Apple-converted-space"> </span><br />+-----------+<span class="Apple-converted-space"> </span><br />| Fibonacci |<span class="Apple-converted-space"> </span><br />+-----------+<span class="Apple-converted-space"> </span><br />| 5 |<span class="Apple-converted-space"> </span><br />| 8 |<span class="Apple-converted-space"> </span><br />+-----------+<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">所以,如果你想在30號值序列和下一個值(<span class="Apple-converted-space"> </span><i>從0開始</i><span class="Apple-converted-space"> </span>)</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />> CALL Fibonacci(30,2,100);<span class="Apple-converted-space"> </span><br />+-----------+<span class="Apple-converted-space"> </span><br />| Fibonacci |<span class="Apple-converted-space"> </span><br />+-----------+<span class="Apple-converted-space"> </span><br />| 832,040 |<span class="Apple-converted-space"> </span><br />| 1,346,269 |<span class="Apple-converted-space"> </span><br />+-----------+<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">所以,如果你想150價值序列和下一個值(<span class="Apple-converted-space"> </span><i>從0開始</i><span class="Apple-converted-space"> </span>)</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />> CALL Fibonacci(150,2,1000);<span class="Apple-converted-space"> </span><br />+--------------------------------------------+<span class="Apple-converted-space"> </span><br />| Fibonacci |<span class="Apple-converted-space"> </span><br />+--------------------------------------------+<span class="Apple-converted-space"> </span><br />| 9,969,216,677,189,305,000,000,000,000,000 |<span class="Apple-converted-space"> </span><br />| 16,130,531,424,904,583,000,000,000,000,000 |<span class="Apple-converted-space"> </span><br />+--------------------------------------------+<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">所以,你的想法。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">現在,您也可以擴大戰果的範圍內,如果你想超過2只更改過程調用的第二個值。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />> CALL Fibonacci(0,10,100);<span class="Apple-converted-space"> </span><br />+-----------+<span class="Apple-converted-space"> </span><br />| Fibonacci |<span class="Apple-converted-space"> </span><br />+-----------+<span class="Apple-converted-space"> </span><br />| 0 |<span class="Apple-converted-space"> </span><br />| 1 |<span class="Apple-converted-space"> </span><br />| 1 |<span class="Apple-converted-space"> </span><br />| 2 |<span class="Apple-converted-space"> </span><br />| 3 |<span class="Apple-converted-space"> </span><br />| 5 |<span class="Apple-converted-space"> </span><br />| 8 |<span class="Apple-converted-space"> </span><br />| 13 |<span class="Apple-converted-space"> </span><br />| 21 |<span class="Apple-converted-space"> </span><br />| 34 |<span class="Apple-converted-space"> </span><br />+-----------+<span class="Apple-converted-space"> </span><br /><br />> CALL Fibonacci(30,5,100);<span class="Apple-converted-space"> </span><br />+-----------+<span class="Apple-converted-space"> </span><br />| Fibonacci |<span class="Apple-converted-space"> </span><br />+-----------+<span class="Apple-converted-space"> </span><br />| 832,040 |<span class="Apple-converted-space"> </span><br />| 1,346,269 |<span class="Apple-converted-space"> </span><br />| 2,178,309 |<span class="Apple-converted-space"> </span><br />| 3,524,578 |<span class="Apple-converted-space"> </span><br />| 5,702,887 |<span class="Apple-converted-space"> </span><br />+-----------+<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: #e6ecf9; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13.1999998092651px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">無論如何,希望有人發現它有用和信用查詢的基礎確實去了原來的職位。</span></div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-60987242724477697592014-12-27T02:16:00.000+08:002014-12-27T02:16:11.023+08:00查找/從字符串中解析字符串<div dir="ltr" style="text-align: left;" trbidi="on">
Original post: <a href="http://anothermysqldba.blogspot.com/2014/12/findparse-string-from-within-string.html">http://anothermysqldba.blogspot.com/2014/12/findparse-string-from-within-string.html</a><br />
<br />
<span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">所以,我注意到了一些不同的問題,並張貼關於解析字符串了另一個字符串最近。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">雖然一些解決方案包括創建新的功能等也可以在某些情況下,一個單一的查詢內完成。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">例如,讓我們說,我們正在尋找拉出從URL域。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">我會盡量細講,為什麼和如何工作的。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">我們有如下表。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br />
<div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />CREATE TABLE `parse_example` (<span class="Apple-converted-space"> </span><br />`id` int(11) NOT NULL AUTO_INCREMENT,<span class="Apple-converted-space"> </span><br />`urldemo` varchar(150) NOT NULL,<span class="Apple-converted-space"> </span><br />PRIMARY KEY (`id`)<span class="Apple-converted-space"> </span><br />) ENGINE=InnoDB;<span class="Apple-converted-space"> </span><br />+----+----------------------------+<span class="Apple-converted-space"> </span><br />| id | urldemo |<span class="Apple-converted-space"> </span><br />+----+----------------------------+<span class="Apple-converted-space"> </span><br />| 1 | http://www.mysql.com/ |<span class="Apple-converted-space"> </span><br />| 2 | http://www.percona.com/ |<span class="Apple-converted-space"> </span><br />| 3 | https://tools.percona.com/ |<span class="Apple-converted-space"> </span><br />| 4 | https://mariadb.com/ |<span class="Apple-converted-space"> </span><br />| 5 | http://planet.mysql.com/ |<span class="Apple-converted-space"> </span><br />| 6 | http://dev.mysql.com/doc/ |<span class="Apple-converted-space"> </span><br />+----+----------------------------+<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">這個例子的目的是無視http://或https://開頭和任何的.COM之後。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">所以我們用locate找到位置。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">在.COM引用是容易的,因為那是恆定的,所以我們可以與啟動。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />SELECT LOCATE('.com', urldemo), urldemo FROM parse_example;<span class="Apple-converted-space"> </span><br />+-------------------------+----------------------------+<span class="Apple-converted-space"> </span><br />| LOCATE('.com', urldemo) | urldemo |<span class="Apple-converted-space"> </span><br />+-------------------------+----------------------------+<span class="Apple-converted-space"> </span><br />| 17 | http://www.mysql.com/ |<span class="Apple-converted-space"> </span><br />| 19 | http://www.percona.com/ |<span class="Apple-converted-space"> </span><br />| 22 | https://tools.percona.com/ |<span class="Apple-converted-space"> </span><br />| 16 | https://mariadb.com/ |<span class="Apple-converted-space"> </span><br />| 20 | http://planet.mysql.com/ |<span class="Apple-converted-space"> </span><br />| 17 | http://dev.mysql.com/doc/ |<span class="Apple-converted-space"> </span><br />+-------------------------+----------------------------+<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">OK,所以我們要刪除的/,什麼地方是什麼?</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />SELECT LOCATE('.com', urldemo) as start, LOCATE('.com', urldemo) +4 as end, SUBSTRING(urldemo FROM LOCATE('.com', urldemo) + 4 ) AS resulting , urldemo FROM parse_example;<span class="Apple-converted-space"> </span><br />+-------+-----+-----------+----------------------------+<span class="Apple-converted-space"> </span><br />| start | end | resulting | urldemo |<span class="Apple-converted-space"> </span><br />+-------+-----+-----------+----------------------------+<span class="Apple-converted-space"> </span><br />| 17 | 21 | / | http://www.mysql.com/ |<span class="Apple-converted-space"> </span><br />| 19 | 23 | / | http://www.percona.com/ |<span class="Apple-converted-space"> </span><br />| 22 | 26 | / | https://tools.percona.com/ |<span class="Apple-converted-space"> </span><br />| 16 | 20 | / | https://mariadb.com/ |<span class="Apple-converted-space"> </span><br />| 20 | 24 | / | http://planet.mysql.com/ |<span class="Apple-converted-space"> </span><br />| 17 | 21 | /doc/ | http://dev.mysql.com/doc/ |<span class="Apple-converted-space"> </span><br />+-------+-----+-----------+----------------------------+</code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">這給了我們我們的最終位置,我只把現場別名使結果更容易執行。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">現在,經過HTTP和HTTPS整理其實是很容易的,以及它們都具有://之後他們,所以我們只需要第二的位置/字符串中。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />SELECT LOCATE('/', urldemo) as first, LOCATE('/', urldemo) +1 as second, urldemo<span class="Apple-converted-space"> </span><br />FROM parse_example;<span class="Apple-converted-space"> </span><br />+-------+--------+----------------------------+<span class="Apple-converted-space"> </span><br />| first | second | urldemo |<span class="Apple-converted-space"> </span><br />+-------+--------+----------------------------+<span class="Apple-converted-space"> </span><br />| 6 | 7 | http://www.mysql.com/ |<span class="Apple-converted-space"> </span><br />| 6 | 7 | http://www.percona.com/ |<span class="Apple-converted-space"> </span><br />| 7 | 8 | https://tools.percona.com/ |<span class="Apple-converted-space"> </span><br />| 7 | 8 | https://mariadb.com/ |<span class="Apple-converted-space"> </span><br />| 6 | 7 | http://planet.mysql.com/ |<span class="Apple-converted-space"> </span><br />| 6 | 7 | http://dev.mysql.com/doc/ |<span class="Apple-converted-space"> </span><br />+-------+--------+----------------------------+<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">這些查詢只是顯示了最終的查詢的不同方面會做。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">因此,讓我們把它放在一起。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />SELECT<span class="Apple-converted-space"> </span><br />TRIM(TRAILING SUBSTRING(urldemo FROM LOCATE('.com', urldemo) + 4 )<span class="Apple-converted-space"> </span><br />FROM SUBSTRING(urldemo FROM LOCATE('/', urldemo) + 2 ) ) AS parsed_domain ,<span class="Apple-converted-space"> </span><br />urldemo as original_url<span class="Apple-converted-space"> </span><br />FROM parse_example;<span class="Apple-converted-space"> </span><br />+-------------------+----------------------------+<span class="Apple-converted-space"> </span><br />| parsed_domain | original_url |<span class="Apple-converted-space"> </span><br />+-------------------+----------------------------+<span class="Apple-converted-space"> </span><br />| www.mysql.com | http://www.mysql.com/ |<span class="Apple-converted-space"> </span><br />| www.percona.com | http://www.percona.com/ |<span class="Apple-converted-space"> </span><br />| tools.percona.com | https://tools.percona.com/ |<span class="Apple-converted-space"> </span><br />| mariadb.com | https://mariadb.com/ |<span class="Apple-converted-space"> </span><br />| planet.mysql.com | http://planet.mysql.com/ |<span class="Apple-converted-space"> </span><br />| dev.mysql.com | http://dev.mysql.com/doc/ |<span class="Apple-converted-space"> </span><br />+-------------------+----------------------------+<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">現在,希望可以幫助您能夠解析出任何你需要的。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">本實施例被限制在一個網址。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">但是,由於功能的一些例子已經在這裡是我的,你可以用它來解析任何你需要的功能的例子。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />CREATE FUNCTION PARSE_STRING(delimiterA VARCHAR(50), delimiterB VARCHAR(50), passed_string VARCHAR(255) )<span class="Apple-converted-space"> </span><br />RETURNS VARCHAR(255) DETERMINISTIC<span class="Apple-converted-space"> </span><br />RETURN<span class="Apple-converted-space"> </span><br />TRIM(TRAILING SUBSTRING(passed_string FROM LOCATE(delimiterB, passed_string) )<span class="Apple-converted-space"> </span><br />FROM SUBSTRING(passed_string FROM LOCATE(delimiterA, passed_string) + CHAR_LENGTH(delimiterA) ) ) ;<span class="Apple-converted-space"> </span><br /><br />SELECT PARSE_STRING('//','.com', urldemo) FROM parse_example;<span class="Apple-converted-space"> </span><br />+------------------------------------+<span class="Apple-converted-space"> </span><br />| PARSE_STRING('//','.com', urldemo) |<span class="Apple-converted-space"> </span><br />+------------------------------------+<span class="Apple-converted-space"> </span><br />| www.mysql |<span class="Apple-converted-space"> </span><br />| www.percona |<span class="Apple-converted-space"> </span><br />| tools.percona |<span class="Apple-converted-space"> </span><br />| mariadb |<span class="Apple-converted-space"> </span><br />| planet.mysql |<span class="Apple-converted-space"> </span><br />| dev.mysql |<span class="Apple-converted-space"> </span><br />+------------------------------------+<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">從全名外地拉一個姓氏:</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />SELECT PARSE_STRING('John ','', 'John Smith') ;<span class="Apple-converted-space"> </span><br />+----------------------------------------+<span class="Apple-converted-space"> </span><br />| PARSE_STRING('John ','', 'John Smith') |<span class="Apple-converted-space"> </span><br />+----------------------------------------+<span class="Apple-converted-space"> </span><br />| Smith |<span class="Apple-converted-space"> </span><br />+----------------------------------------+<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">拉頭名</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />SELECT PARSE_STRING('',' Smith', 'John Smith') ;<span class="Apple-converted-space"> </span><br />+-----------------------------------------+<span class="Apple-converted-space"> </span><br />| PARSE_STRING('',' Smith', 'John Smith') |<span class="Apple-converted-space"> </span><br />+-----------------------------------------+<span class="Apple-converted-space"> </span><br />| John |<span class="Apple-converted-space"> </span><br />+-----------------------------------------+<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">授予的名稱例子,你需要知道的分隔符值。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">但是,這只是一個例子,你可以建立在。</span></div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-14684521002197747262014-12-19T09:38:00.002+08:002014-12-19T09:38:22.542+08:00一個MySQL分區和SUBPARTITION示例<div dir="ltr" style="text-align: left;" trbidi="on">
Original post: <a href="http://anothermysqldba.blogspot.com/2014/12/a-mysql-partition-and-subpartition.html">http://anothermysqldba.blogspot.com/2014/12/a-mysql-partition-and-subpartition.html</a><br />
<br />
<span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">因此,這是一個如何建立一個分區和MySQL的一個SUBPARTITION只是一個簡單的例子。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">這裡的概念是,你必須在一個時間字段無數值表中的數據。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">你可能有分佈在很多年(最有可能的,你做的)數據。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">所以這個分區數據的一種方法是通過一年來排序,但隨後也即每年分區內按月份排序。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">以下是你可以用考慮一個例子。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">考慮到測試表。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">你的表當然有更多的領域。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br />
<div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />CREATE TABLE `t1` (<span class="Apple-converted-space"> </span><br />`id` int(11) NOT NULL AUTO_INCREMENT,<span class="Apple-converted-space"> </span><br />`date_time` datetime DEFAULT NOW(),<span class="Apple-converted-space"> </span><br />PRIMARY KEY (`id`)<span class="Apple-converted-space"> </span><br />) ENGINE=InnoDB;<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">首先,我將填充測試表隨機值的DATE_TIME領域。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />delimiter //<span class="Apple-converted-space"> </span><br />CREATE PROCEDURE populate_t1( IN rowsofdata INT )<span class="Apple-converted-space"> </span><br />BEGIN<span class="Apple-converted-space"> </span><br /><br />SET @A = 1;<span class="Apple-converted-space"> </span><br />SET @B = 25 - @A;<span class="Apple-converted-space"> </span><br /><br />WHILE rowsofdata > 0 DO<span class="Apple-converted-space"> </span><br />SELECT FLOOR( @A + (RAND() * @B )) INTO @randvalue;<span class="Apple-converted-space"> </span><br />INSERT INTO t1<span class="Apple-converted-space"> </span><br />SELECT NULL, NOW() - INTERVAL @randvalue MONTH;<span class="Apple-converted-space"> </span><br />SET rowsofdata = rowsofdata - 1;<span class="Apple-converted-space"> </span><br />END WHILE;<span class="Apple-converted-space"> </span><br />END//<span class="Apple-converted-space"> </span><br />delimiter ;<span class="Apple-converted-space"> </span><br />call populate_t1(1000);<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">檢查,看看我結束了什麼樣的價值觀為:</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />> SELECT COUNT(*) FROM t1 WHERE date_time BETWEEN '2012-01-01 00:00:00' AND '2013-01-01 00:00:00'\G<span class="Apple-converted-space"> </span><br />*************************** 1. row ***************************<span class="Apple-converted-space"> </span><br />COUNT(*): 43<span class="Apple-converted-space"> </span><br />1 row in set (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />> SELECT COUNT(*) FROM t1 WHERE date_time BETWEEN '2013-01-01 00:00:00' AND '2014-01-01 00:00:00'\G<span class="Apple-converted-space"> </span><br />*************************** 1. row ***************************<span class="Apple-converted-space"> </span><br />COUNT(*): 529<span class="Apple-converted-space"> </span><br />1 row in set (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />> SELECT COUNT(*) FROM t1 WHERE date_time BETWEEN '2014-01-01 00:00:00' AND NOW() \G<br />*************************** 1. row ***************************<span class="Apple-converted-space"> </span><br />COUNT(*): 428<span class="Apple-converted-space"> </span><br />1 row in set (0.00 sec)<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">現在,我可以改變表,所以我可以通過分區添加我的分區,然後測試值計數。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY (`id`,`date_time`), LOCK=SHARED;<span class="Apple-converted-space"> </span><br />ALTER TABLE t1<span class="Apple-converted-space"> </span><br />PARTITION BY RANGE( YEAR(date_time) )<span class="Apple-converted-space"> </span><br />SUBPARTITION BY HASH(MONTH(date_time) ) (<span class="Apple-converted-space"> </span><br /><br />PARTITION p2012 VALUES LESS THAN (2013) (<span class="Apple-converted-space"> </span><br />SUBPARTITION dec_2012,<span class="Apple-converted-space"> </span><br />SUBPARTITION jan_2012,<span class="Apple-converted-space"> </span><br />SUBPARTITION feb_2012,<span class="Apple-converted-space"> </span><br />SUBPARTITION mar_2012,<span class="Apple-converted-space"> </span><br />SUBPARTITION apr_2012,<span class="Apple-converted-space"> </span><br />SUBPARTITION may_2012,<span class="Apple-converted-space"> </span><br />SUBPARTITION jun_2012,<span class="Apple-converted-space"> </span><br />SUBPARTITION jul_2012,<span class="Apple-converted-space"> </span><br />SUBPARTITION aug_2012,<span class="Apple-converted-space"> </span><br />SUBPARTITION sep_2012,<span class="Apple-converted-space"> </span><br />SUBPARTITION oct_2012,<span class="Apple-converted-space"> </span><br />SUBPARTITION nov_2012<span class="Apple-converted-space"> </span><br />),<span class="Apple-converted-space"> </span><br /><br />PARTITION p2013 VALUES LESS THAN (2014) (<span class="Apple-converted-space"> </span><br />SUBPARTITION dec_2013,<span class="Apple-converted-space"> </span><br />SUBPARTITION jan_2013,<span class="Apple-converted-space"> </span><br />SUBPARTITION feb_2013,<span class="Apple-converted-space"> </span><br />SUBPARTITION mar_2013,<span class="Apple-converted-space"> </span><br />SUBPARTITION apr_2013,<span class="Apple-converted-space"> </span><br />SUBPARTITION may_2013,<span class="Apple-converted-space"> </span><br />SUBPARTITION jun_2013,<span class="Apple-converted-space"> </span><br />SUBPARTITION jul_2013,<span class="Apple-converted-space"> </span><br />SUBPARTITION aug_2013,<span class="Apple-converted-space"> </span><br />SUBPARTITION sep_2013,<span class="Apple-converted-space"> </span><br />SUBPARTITION oct_2013,<span class="Apple-converted-space"> </span><br />SUBPARTITION nov_2013<span class="Apple-converted-space"> </span><br /><br />),<span class="Apple-converted-space"> </span><br />PARTITION p2014 VALUES LESS THAN (2015) (<span class="Apple-converted-space"> </span><br />SUBPARTITION dec_2014,<span class="Apple-converted-space"> </span><br />SUBPARTITION jan_2014,<span class="Apple-converted-space"> </span><br />SUBPARTITION feb_2014,<span class="Apple-converted-space"> </span><br />SUBPARTITION mar_2014,<span class="Apple-converted-space"> </span><br />SUBPARTITION apr_2014,<span class="Apple-converted-space"> </span><br />SUBPARTITION may_2014,<span class="Apple-converted-space"> </span><br />SUBPARTITION jun_2014,<span class="Apple-converted-space"> </span><br />SUBPARTITION jul_2014,<span class="Apple-converted-space"> </span><br />SUBPARTITION aug_2014,<span class="Apple-converted-space"> </span><br />SUBPARTITION sep_2014,<span class="Apple-converted-space"> </span><br />SUBPARTITION oct_2014,<span class="Apple-converted-space"> </span><br />SUBPARTITION nov_2014<span class="Apple-converted-space"> </span><br />),<span class="Apple-converted-space"> </span><br /><br />PARTITION pmax VALUES LESS THAN MAXVALUE (<span class="Apple-converted-space"> </span><br />SUBPARTITION dec_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION jan_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION feb_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION mar_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION apr_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION may_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION jun_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION jul_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION aug_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION sep_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION oct_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION nov_max<span class="Apple-converted-space"> </span><br />)<span class="Apple-converted-space"> </span><br />);<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">我型我秀創建表非常不同了。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />> show create table t1;<span class="Apple-converted-space"> </span><br />CREATE TABLE `t1` (<span class="Apple-converted-space"> </span><br />`id` int(11) NOT NULL AUTO_INCREMENT,<span class="Apple-converted-space"> </span><br />`date_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,<span class="Apple-converted-space"> </span><br />PRIMARY KEY (`id`,`date_time`)<span class="Apple-converted-space"> </span><br />) ENGINE=InnoDB AUTO_INCREMENT=1001 DEFAULT CHARSET=latin1<span class="Apple-converted-space"> </span><br />/*!50100 PARTITION BY RANGE ( YEAR(date_time))<span class="Apple-converted-space"> </span><br />SUBPARTITION BY HASH (MONTH(date_time))<span class="Apple-converted-space"> </span><br />(PARTITION p2012 VALUES LESS THAN (2013)<span class="Apple-converted-space"> </span><br />(SUBPARTITION dec_2012 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION jan_2012 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION feb_2012 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION mar_2012 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION apr_2012 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION may_2012 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION jun_2012 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION jul_2012 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION aug_2012 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION sep_2012 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION oct_2012 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION nov_2012 ENGINE = InnoDB),<span class="Apple-converted-space"> </span><br />PARTITION p2013 VALUES LESS THAN (2014)<span class="Apple-converted-space"> </span><br />(SUBPARTITION dec_2013 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION jan_2013 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION feb_2013 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION mar_2013 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION apr_2013 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION may_2013 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION jun_2013 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION jul_2013 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION aug_2013 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION sep_2013 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION oct_2013 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION nov_2013 ENGINE = InnoDB),<span class="Apple-converted-space"> </span><br />PARTITION p2014 VALUES LESS THAN (2015)<span class="Apple-converted-space"> </span><br />(SUBPARTITION dec_2014 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION jan_2014 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION feb_2014 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION mar_2014 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION apr_2014 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION may_2014 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION jun_2014 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION jul_2014 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION aug_2014 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION sep_2014 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION oct_2014 ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION nov_2014 ENGINE = InnoDB),<span class="Apple-converted-space"> </span><br />PARTITION pmax VALUES LESS THAN MAXVALUE<span class="Apple-converted-space"> </span><br />(SUBPARTITION dec_max ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION jan_max ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION feb_max ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION mar_max ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION apr_max ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION may_max ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION jun_max ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION jul_max ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION aug_max ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION sep_max ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION oct_max ENGINE = InnoDB,<span class="Apple-converted-space"> </span><br />SUBPARTITION nov_max ENGINE = InnoDB))<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">所以,我們還能指望我們的價值預期?</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />> SELECT count(*) FROM t1 PARTITION (p2012) \G<span class="Apple-converted-space"> </span><br />*************************** 1. row ***************************<span class="Apple-converted-space"> </span><br />count(*): 43<span class="Apple-converted-space"> </span><br />> SELECT count(*) FROM t1 PARTITION (p2013) \G<span class="Apple-converted-space"> </span><br />*************************** 1. row ***************************<span class="Apple-converted-space"> </span><br />count(*): 529<span class="Apple-converted-space"> </span><br />> SELECT count(*) FROM t1 PARTITION (p2014) \G<span class="Apple-converted-space"> </span><br />*************************** 1. row ***************************<span class="Apple-converted-space"> </span><br />count(*): 428<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">到目前為止好,所有的價值觀匹配了我們所收到的數量。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">所以我們也可以算或每子分區中進行選擇。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />> SELECT * FROM t1 PARTITION (dec_2012) limit 5;<span class="Apple-converted-space"> </span><br />+-----+---------------------+<span class="Apple-converted-space"> </span><br />| id | date_time |<span class="Apple-converted-space"> </span><br />+-----+---------------------+<span class="Apple-converted-space"> </span><br />| 59 | 2012-12-19 00:59:57 |<span class="Apple-converted-space"> </span><br />| 68 | 2012-12-19 00:59:58 |<span class="Apple-converted-space"> </span><br />| 93 | 2012-12-19 00:59:59 |<span class="Apple-converted-space"> </span><br />| 105 | 2012-12-19 00:59:59 |<span class="Apple-converted-space"> </span><br />| 111 | 2012-12-19 00:59:59 |<span class="Apple-converted-space"> </span><br />+-----+---------------------+<span class="Apple-converted-space"> </span><br /><br />> SELECT * FROM t1 PARTITION (jan_2013) limit 5;<span class="Apple-converted-space"> </span><br />+-----+---------------------+<span class="Apple-converted-space"> </span><br />| id | date_time |<span class="Apple-converted-space"> </span><br />+-----+---------------------+<span class="Apple-converted-space"> </span><br />| 6 | 2013-01-19 00:59:55 |<span class="Apple-converted-space"> </span><br />| 29 | 2013-01-19 00:59:56 |<span class="Apple-converted-space"> </span><br />| 55 | 2013-01-19 00:59:57 |<span class="Apple-converted-space"> </span><br />| 79 | 2013-01-19 00:59:58 |<span class="Apple-converted-space"> </span><br />| 100 | 2013-01-19 00:59:59 |<span class="Apple-converted-space"> </span><br />+-----+---------------------+<span class="Apple-converted-space"> </span><br /><br />> SELECT * FROM t1 PARTITION (jan_2014) limit 5;<span class="Apple-converted-space"> </span><br />+-----+---------------------+<span class="Apple-converted-space"> </span><br />| id | date_time |<span class="Apple-converted-space"> </span><br />+-----+---------------------+<span class="Apple-converted-space"> </span><br />| 16 | 2014-01-19 00:59:55 |<span class="Apple-converted-space"> </span><br />| 190 | 2014-01-19 01:00:04 |<span class="Apple-converted-space"> </span><br />| 191 | 2014-01-19 01:00:04 |<span class="Apple-converted-space"> </span><br />| 229 | 2014-01-19 01:00:05 |<span class="Apple-converted-space"> </span><br />| 234 | 2014-01-19 01:00:06 |<span class="Apple-converted-space"> </span><br />+-----+---------------------+<span class="Apple-converted-space"> </span><br /><br />> SELECT * FROM t1 PARTITION (jun_2014) limit 5;<span class="Apple-converted-space"> </span><br />+-----+---------------------+<span class="Apple-converted-space"> </span><br />| id | date_time |<span class="Apple-converted-space"> </span><br />+-----+---------------------+<span class="Apple-converted-space"> </span><br />| 13 | 2014-06-19 00:59:55 |<span class="Apple-converted-space"> </span><br />| 189 | 2014-06-19 01:00:04 |<span class="Apple-converted-space"> </span><br />| 221 | 2014-06-19 01:00:05 |<span class="Apple-converted-space"> </span><br />| 222 | 2014-06-19 01:00:05 |<span class="Apple-converted-space"> </span><br />| 238 | 2014-06-19 01:00:06 |<span class="Apple-converted-space"> </span><br />+-----+---------------------+<span class="Apple-converted-space"> </span><br /><br />> SELECT * FROM t1 PARTITION (dec_2013) limit 5;<span class="Apple-converted-space"> </span><br />+-----+---------------------+<span class="Apple-converted-space"> </span><br />| id | date_time |<span class="Apple-converted-space"> </span><br />+-----+---------------------+<span class="Apple-converted-space"> </span><br />| 50 | 2013-12-19 00:59:57 |<span class="Apple-converted-space"> </span><br />| 74 | 2013-12-19 00:59:58 |<span class="Apple-converted-space"> </span><br />| 98 | 2013-12-19 00:59:59 |<span class="Apple-converted-space"> </span><br />| 107 | 2013-12-19 00:59:59 |<span class="Apple-converted-space"> </span><br />| 167 | 2013-12-19 01:00:02 |<span class="Apple-converted-space"> </span><br />+-----+---------------------+<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">這是偉大的,方便的,但是,當2015年或2016年左右出現什麼情況?</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">所有這些數據將在PMAX分區。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">那麼,我們如何P2014和Pmax的在增加一個新的分區?</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">如果您在PMAX沒有數據,你可以刪除它並添加一個新的分區到年底。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">但它也很容易重新組織的分區。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">這將需要的PMAX分區,改變成我們新的分區。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />ALTER TABLE t1 REORGANIZE PARTITION pmax INTO (<span class="Apple-converted-space"> </span><br />PARTITION p2015 VALUES LESS THAN (2016) (<span class="Apple-converted-space"> </span><br />SUBPARTITION dec_2015,<span class="Apple-converted-space"> </span><br />SUBPARTITION jan_2015,<span class="Apple-converted-space"> </span><br />SUBPARTITION feb_2015,<span class="Apple-converted-space"> </span><br />SUBPARTITION mar_2015,<span class="Apple-converted-space"> </span><br />SUBPARTITION apr_2015,<span class="Apple-converted-space"> </span><br />SUBPARTITION may_2015,<span class="Apple-converted-space"> </span><br />SUBPARTITION jun_2015,<span class="Apple-converted-space"> </span><br />SUBPARTITION jul_2015,<span class="Apple-converted-space"> </span><br />SUBPARTITION aug_2015,<span class="Apple-converted-space"> </span><br />SUBPARTITION sep_2015,<span class="Apple-converted-space"> </span><br />SUBPARTITION oct_2015,<span class="Apple-converted-space"> </span><br />SUBPARTITION nov_2015<span class="Apple-converted-space"> </span><br />),<span class="Apple-converted-space"> </span><br />PARTITION pmax VALUES LESS THAN MAXVALUE (<span class="Apple-converted-space"> </span><br />SUBPARTITION dec_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION jan_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION feb_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION mar_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION apr_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION may_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION jun_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION jul_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION aug_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION sep_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION oct_max,<span class="Apple-converted-space"> </span><br />SUBPARTITION nov_max<span class="Apple-converted-space"> </span><br />)<span class="Apple-converted-space"> </span><br />);<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">希望這可以幫助,好運。</span></div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-23237731676450549642014-11-28T04:17:00.001+08:002014-11-28T04:17:24.068+08:00與mysqlbinlog可以點時間恢復例如恢復丟失的MySQL數據<div dir="ltr" style="text-align: left;" trbidi="on">
Original post: <a href="http://anothermysqldba.blogspot.com/2014/11/recover-lost-mysql-data-with.html">http://anothermysqldba.blogspot.com/2014/11/recover-lost-mysql-data-with.html</a><br />
<br />
<div class="post-body entry-content" id="post-body-6617143744332273895" itemprop="description articleBody" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.4; orphans: auto; position: relative; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 766px; word-spacing: 0px;">
<div dir="ltr" style="text-align: left;">
<span class="notranslate">備份...備份...備份...但當然..你還需要監控和測試這些備份通常否則他們可能是毫無價值的。</span><span class="Apple-converted-space"> </span><span class="notranslate">有你的MySQL<span class="Apple-converted-space"> </span><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&tl=zh-TW&u=http://dev.mysql.com/doc/refman/5.6/en/binary-log.html&usg=ALkJrhglaTtunTHWK2jpDtJS6SHYyzqriQ" style="color: #888888; text-decoration: none;">binlogs</a>啟用一定可以幫助你在緊急的時候也是如此。</span><span class="Apple-converted-space"> </span><span class="notranslate">MySQL的binlogs經常在關於MySQL複製引用,一個很好的理由,他們店裡所有的更改數據(查詢或事件的<a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&tl=zh-TW&u=http://dev.mysql.com/doc/refman/5.6/en/binary-log-formats.html&usg=ALkJrhhNqUWoW-udFmbTDS2M-2kbwwrs2g" style="color: #888888; text-decoration: none;">基於行的</a>有一點不同,但這樣的例子)。</span><span class="Apple-converted-space"> </span><span class="notranslate">在binlogs對服務器性能的影響微乎其微考慮它們所提供的恢復選項的時候。</span><span class="Apple-converted-space"> </span><br /><br /><div class="codebox" style="background-color: #eeeeff; border: 1px solid black; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;"><br />[anothermysqldba]> show variables like 'log_bin%';<span class="Apple-converted-space"> </span><br />+---------------------------------+--------------------------------------------+<span class="Apple-converted-space"> </span><br />| Variable_name | Value |<span class="Apple-converted-space"> </span><br />+---------------------------------+--------------------------------------------+<span class="Apple-converted-space"> </span><br />| log_bin | ON |<span class="Apple-converted-space"> </span><br />| log_bin_basename | /var/lib/mysql/binlogs/mysql-binlogs |<span class="Apple-converted-space"> </span><br />| log_bin_index | /var/lib/mysql/binlogs/mysql-binlogs.index |<span class="Apple-converted-space"> </span><br /><br />show variables like 'binlog_format%';<span class="Apple-converted-space"> </span><br />+---------------+-------+<span class="Apple-converted-space"> </span><br />| Variable_name | Value |<span class="Apple-converted-space"> </span><br />+---------------+-------+<span class="Apple-converted-space"> </span><br />| binlog_format | MIXED |<span class="Apple-converted-space"> </span><br />+---------------+-------+<span class="Apple-converted-space"> </span></code></div>
<br /><br /><span class="notranslate">因此,這是一個使用mysqlbinlog可以恢復來自一個二進制日誌數據,並將其應用到數據庫只是一個簡單的例子。</span><span class="Apple-converted-space"> </span><br /><br /><span class="notranslate">首先,我們需要的東西鬆動。</span><span class="Apple-converted-space"> </span><span class="notranslate">如果事情是發生在我們的數據庫中,我們需要能夠恢復數據也許它只是一種方式,從某人的失誤中恢復過來。</span><span class="Apple-converted-space"> </span><br /><br /><div class="codebox" style="background-color: #eeeeff; border: 1px solid black; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;"><br />CREATE TABLE `table_w_rdata` (<span class="Apple-converted-space"> </span><br />`id` int(11) NOT NULL AUTO_INCREMENT,<span class="Apple-converted-space"> </span><br />`somedata` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,<span class="Apple-converted-space"> </span><br />`moredata` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,<span class="Apple-converted-space"> </span><br />PRIMARY KEY (`id`)<span class="Apple-converted-space"> </span><br />) ENGINE=InnoDB;<span class="Apple-converted-space"> </span></code></div>
<br /><span class="notranslate">我們可以在這裡假裝和假設我們有開發人員/ DBA的未溝通非常好和/或保存其代碼的副本。</span><span class="Apple-converted-space"> </span><br /><br /><div class="codebox" style="background-color: #eeeeff; border: 1px solid black; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;"><br />delimiter //<span class="Apple-converted-space"> </span><br />CREATE PROCEDURE populate_dummydata( IN rowsofdata INT )<span class="Apple-converted-space"> </span><br />BEGIN<span class="Apple-converted-space"> </span><br /><br />SET @A = 3;<span class="Apple-converted-space"> </span><br />SET @B = 15 - @A;<span class="Apple-converted-space"> </span><br />SET @C = 16;<span class="Apple-converted-space"> </span><br />SET @D = 25 - @C;<span class="Apple-converted-space"> </span><br /><br />WHILE rowsofdata > 0 DO<span class="Apple-converted-space"> </span><br />INSERT INTO table_w_rdata<span class="Apple-converted-space"> </span><br />SELECT NULL, SUBSTR(md5(''),FLOOR( @A + (RAND() * @B ))) as somedata, SUBSTR(md5(''),FLOOR( @C + (RAND() * @D ))) AS moredata ;<span class="Apple-converted-space"> </span><br />SET rowsofdata = rowsofdata - 1;<span class="Apple-converted-space"> </span><br />END WHILE;<span class="Apple-converted-space"> </span><br />END//<span class="Apple-converted-space"> </span><br />delimiter ;<span class="Apple-converted-space"> </span><br />call populate_dummydata(50);<span class="Apple-converted-space"> </span><br /><br />> SELECT NOW() \G<span class="Apple-converted-space"> </span><br />*************************** 1. row ***************************<span class="Apple-converted-space"> </span><br />NOW(): 2014-11-27 17:32:25<span class="Apple-converted-space"> </span><br />1 row in set (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />> SELECT * from table_w_rdata WHERE id > 45;<span class="Apple-converted-space"> </span><br />+----+----------------------------+------------------+<span class="Apple-converted-space"> </span><br />| id | somedata | moredata |<span class="Apple-converted-space"> </span><br />+----+----------------------------+------------------+<span class="Apple-converted-space"> </span><br />| 46 | b204e9800998ecf8427e | 0998ecf8427e |<span class="Apple-converted-space"> </span><br />| 47 | d98f00b204e9800998ecf8427e | 8ecf8427e |<span class="Apple-converted-space"> </span><br />| 48 | b204e9800998ecf8427e | 800998ecf8427e |<span class="Apple-converted-space"> </span><br />| 49 | 98f00b204e9800998ecf8427e | e9800998ecf8427e |<span class="Apple-converted-space"> </span><br />| 50 | 98f00b204e9800998ecf8427e | 998ecf8427e |<span class="Apple-converted-space"> </span><br />+----+----------------------------+------------------+<span class="Apple-converted-space"> </span></code></div>
<br /><span class="notranslate">同時創建一個過程中它以後在寫別人不正確。</span><span class="Apple-converted-space"> </span><br /><div class="codebox" style="background-color: #eeeeff; border: 1px solid black; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;"><br />DROP PROCEDURE IF EXISTS populate_dummydata ;<span class="Apple-converted-space"> </span><br />delimiter //<span class="Apple-converted-space"> </span><br />CREATE PROCEDURE populate_dummydata( IN rowsofdata INT )<span class="Apple-converted-space"> </span><br />BEGIN<span class="Apple-converted-space"> </span><br /><br />SET @A = 3;<span class="Apple-converted-space"> </span><br />SET @B = 15 - @A;<span class="Apple-converted-space"> </span><br />SET @C = 16;<span class="Apple-converted-space"> </span><br />SET @D = 25 - @C;<span class="Apple-converted-space"> </span><br /><br />WHILE rowsofdata > 0 DO<span class="Apple-converted-space"> </span><br />INSERT INTO table_w_rdata<span class="Apple-converted-space"> </span><br />SELECT NULL, SUBSTR(md5(''),FLOOR( @C + (RAND() * @A ))) as somedata, SUBSTR(md5(''),FLOOR( @B + (RAND() * @D ))) AS moredata ;<span class="Apple-converted-space"> </span><br />SET rowsofdata = rowsofdata - 1;<span class="Apple-converted-space"> </span><br />END WHILE;<span class="Apple-converted-space"> </span><br />END//<span class="Apple-converted-space"> </span><br />delimiter ;<span class="Apple-converted-space"> </span><br /><br />call populate_dummydata(50);<span class="Apple-converted-space"> </span><br />> SELECT NOW(); SELECT * from table_w_rdata WHERE id > 95;<span class="Apple-converted-space"> </span><br />+---------------------+<span class="Apple-converted-space"> </span><br />| NOW() |<span class="Apple-converted-space"> </span><br />+---------------------+<span class="Apple-converted-space"> </span><br />| 2014-11-27 17:36:28 |<span class="Apple-converted-space"> </span><br />+---------------------+<span class="Apple-converted-space"> </span><br />1 row in set (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />+-----+-------------------+---------------------+<span class="Apple-converted-space"> </span><br />| id | somedata | moredata |<span class="Apple-converted-space"> </span><br />+-----+-------------------+---------------------+<span class="Apple-converted-space"> </span><br />| 96 | 4e9800998ecf8427e | 00998ecf8427e |<span class="Apple-converted-space"> </span><br />| 97 | 9800998ecf8427e | 800998ecf8427e |<span class="Apple-converted-space"> </span><br />| 98 | e9800998ecf8427e | 204e9800998ecf8427e |<span class="Apple-converted-space"> </span><br />| 99 | e9800998ecf8427e | 4e9800998ecf8427e |<span class="Apple-converted-space"> </span><br />| 100 | 9800998ecf8427e | 04e9800998ecf8427e |<span class="Apple-converted-space"> </span><br />+-----+-------------------+---------------------+<span class="Apple-converted-space"> </span></code></div>
<br /><br /><span class="notranslate">該過程的替換版本不會產生隨機值,如團隊希望。</span><span class="Apple-converted-space"> </span><span class="notranslate">該過程的原創者剛從無奈退出。</span><span class="Apple-converted-space"> </span><span class="notranslate">那麼怎麼辦?</span><span class="Apple-converted-space"> </span><span class="notranslate">時間一點點過去有,因為它創建為好。</span><span class="Apple-converted-space"> </span><span class="notranslate">我們知道數據庫名稱,例程名和一般時間框架在創建時不正確的程序和幸運,我們的bin日誌仍然存在,所以我們可以去得到它。</span><span class="Apple-converted-space"> </span><br /><br /><span class="notranslate">我們必須採取一般環顧四周,因為我們只想要一個<a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&tl=zh-TW&u=http://dev.mysql.com/doc/refman/5.6/en/point-in-time-recovery.html&usg=ALkJrhgmr4uL3Q_ZVp3Y0ZDSS5sJVCyzVA" style="color: #888888; text-decoration: none;">點時恢復</a>該procedure.We中偶然發現的過程,並在之前和之後的二進制日誌的位置。</span><span class="Apple-converted-space"> </span><br /><br /><div class="codebox" style="background-color: #eeeeff; border: 1px solid black; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;"><br />NOW(): 2014-11-27 19:46:17<span class="Apple-converted-space"> </span><br /># mysqlbinlog --start-datetime=20141127173200 --stop-datetime=20141127173628 --database=anothermysqldba mysql-binlogs.000001 | more<span class="Apple-converted-space"> </span><br /><br />at 253053<span class="Apple-converted-space"> </span><br />at 253564<span class="Apple-converted-space"> </span><br /><br /># mysql anothermysqldba<span class="Apple-converted-space"> </span><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&tl=zh-TW&u=http://anothermysqldba.blogspot.com/2013/05/mysql-users-grants-mysqlconfigeditor.html&usg=ALkJrhhBznhSq-NhhevrIragQ7rijiYeww" style="color: #888888; text-decoration: none;">--login-path</a><span class="Apple-converted-space"> </span>=local -e "DROP PROCEDURE populate_dummydata";<span class="Apple-converted-space"> </span><br /># mysqlbinlog --start-position=253053 --stop-position=253564 --database=anothermysqldba mysql-binlogs.000001 | mysql<span class="Apple-converted-space"> </span><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&tl=zh-TW&u=http://anothermysqldba.blogspot.com/2013/05/mysql-users-grants-mysqlconfigeditor.html&usg=ALkJrhhBznhSq-NhhevrIragQ7rijiYeww" style="color: #888888; text-decoration: none;">--login-path</a><span class="Apple-converted-space"> </span>=local anothermysqldba<span class="Apple-converted-space"> </span><br /><br /><br />> SHOW CREATE PROCEDURE populate_dummydata\G<span class="Apple-converted-space"> </span><br />*************************** 1. row ***************************<span class="Apple-converted-space"> </span><br />Procedure: populate_dummydata<span class="Apple-converted-space"> </span><br />sql_mode: NO_AUTO_VALUE_ON_ZERO,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION<span class="Apple-converted-space"> </span><br />Create Procedure: CREATE DEFINER=`root`@`localhost` PROCEDURE `populate_dummydata`( IN rowsofdata INT )<span class="Apple-converted-space"> </span><br />BEGIN<span class="Apple-converted-space"> </span><br /><br />SET @A = 3;<span class="Apple-converted-space"> </span><br />SET @B = 15 - @A;<span class="Apple-converted-space"> </span><br />SET @C = 16;<span class="Apple-converted-space"> </span><br />SET @D = 25 - @C;<span class="Apple-converted-space"> </span><br /><br />WHILE rowsofdata > 0 DO<span class="Apple-converted-space"> </span><br />INSERT INTO table_w_rdata<span class="Apple-converted-space"> </span><br />SELECT NULL, SUBSTR(md5(''),FLOOR( @A + (RAND() * @B ))) as somedata, SUBSTR(md5(''),FLOOR( @C + (RAND() * @D ))) AS moredata ;<span class="Apple-converted-space"> </span><br />SET rowsofdata = rowsofdata - 1;<span class="Apple-converted-space"> </span><br />END WHILE;<span class="Apple-converted-space"> </span><br />END<span class="Apple-converted-space"> </span><br />character_set_client: utf8<span class="Apple-converted-space"> </span><br />collation_connection: utf8_general_ci<span class="Apple-converted-space"> </span><br />Database Collation: latin1_swedish_ci<span class="Apple-converted-space"> </span><br />1 row in set (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />NOW(): 2014-11-27 19:51:03<span class="Apple-converted-space"> </span><br />> call populate_dummydata(50);<span class="Apple-converted-space"> </span><br />> SELECT * from table_w_rdata WHERE id > 145;<span class="Apple-converted-space"> </span><br />+-----+-----------------------------+------------------+<span class="Apple-converted-space"> </span><br />| id | somedata | moredata |<span class="Apple-converted-space"> </span><br />+-----+-----------------------------+------------------+<span class="Apple-converted-space"> </span><br />| 146 | 98f00b204e9800998ecf8427e | 800998ecf8427e |<span class="Apple-converted-space"> </span><br />| 147 | cd98f00b204e9800998ecf8427e | 800998ecf8427e |<span class="Apple-converted-space"> </span><br />| 148 | 204e9800998ecf8427e | 98ecf8427e |<span class="Apple-converted-space"> </span><br />| 149 | d98f00b204e9800998ecf8427e | e9800998ecf8427e |<span class="Apple-converted-space"> </span><br />| 150 | 204e9800998ecf8427e | 9800998ecf8427e |<span class="Apple-converted-space"> </span><br />+-----+-----------------------------+------------------+<span class="Apple-converted-space"> </span></code></div>
<br /><br /><span class="notranslate">我們通過我們的恢復從二進制日誌程序<a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&tl=zh-TW&u=http://dev.mysql.com/doc/refman/5.6/en/point-in-time-recovery.html&usg=ALkJrhgmr4uL3Q_ZVp3Y0ZDSS5sJVCyzVA" style="color: #888888; text-decoration: none;">點時間恢復</a><span class="Apple-converted-space"> </span>。</span><span class="Apple-converted-space"> </span><br /><span class="notranslate">這是一個簡單的例子,但它是你可以用前進的工具的一個例子。</span><span class="Apple-converted-space"> </span><br /><br /><span class="notranslate">這就是為什麼binlogs是如此寶貴。</span><span class="Apple-converted-space"> </span><br /><br /><span class="notranslate">有用的網址:</span><span class="Apple-converted-space"> </span><br /><ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em; text-align: left;">
<li style="margin: 0px 0px 0.25em; padding: 0px; text-indent: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&tl=zh-TW&u=http://dev.mysql.com/doc/refman/5.6/en/binary-log.html&usg=ALkJrhglaTtunTHWK2jpDtJS6SHYyzqriQ" style="color: #888888; text-decoration: none;">http://dev.mysql.com/doc/refman/5.6/en/binary-log.html</a></span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px; text-indent: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&tl=zh-TW&u=http://dev.mysql.com/doc/refman/5.6/en/point-in-time-recovery.html&usg=ALkJrhgmr4uL3Q_ZVp3Y0ZDSS5sJVCyzVA" style="color: #888888; text-decoration: none;">http://dev.mysql.com/doc/refman/5.6/en/point-in-time-recovery.html</a></span></li>
</ul>
</div>
</div>
<div class="post-footer" style="-webkit-text-stroke-width: 0px; background-color: #eeeeee; border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.6; margin: 20px -2px 0px; orphans: auto; padding: 5px 10px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<br class="Apple-interchange-newline" /></div>
</div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-84065643234137910422014-11-12T06:25:00.001+08:002014-11-12T06:25:25.170+08:00systemctl和MySQL<div dir="ltr" style="text-align: left;" trbidi="on">
Original post: <a href="http://anothermysqldba.blogspot.com/2014/11/systemctl-and-mysql.html">http://anothermysqldba.blogspot.com/2014/11/systemctl-and-mysql.html </a><br />
<br />
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<span class="notranslate">所以一些用戶完成百勝安裝的MySQL,並期望能夠使用下面的命令來啟動MySQL服務器:: /etc/init.d/mysql才開始得到“沒有這樣的文件或目錄”</span></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<span class="notranslate">因此,這是一個快速的職位,以幫助使用systemctl命令。</span></div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<span class="notranslate">你很可能會看到以下內容:</span></div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<div class="codebox" style="background-color: #eeeeff; border: 1px solid black; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;"># systemctl list-unit-files | grep mysql<span class="Apple-converted-space"> </span><br />mysqld.service disabled</code></div>
</div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<span class="notranslate">首先,我會建議去<a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&tl=zh-TW&u=http://tools.percona.com/&usg=ALkJrhjv5dOOvfmO5pPe3Mb_gHvHxj7Jsw" style="color: #888888; text-decoration: none;">tools.percona.com</a>並創建一個有效的my.cnf文件。</span></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<span class="notranslate">因此,解決辦法很簡單,我們只需要啟用此所以數據庫可以在服務器啟動啟動。</span></div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<br /><div class="codebox" style="background-color: #eeeeff; border: 1px solid black; overflow: auto; padding: 10px; width: 600px;">
<code style="font-size: 0.9em;">#systemctl enable mysqld.service<span class="Apple-converted-space"> </span><br />ln -s '/usr/lib/systemd/system/mysqld.service' '/etc/systemd/system/mysql.service'<span class="Apple-converted-space"> </span><br />ln -s '/usr/lib/systemd/system/mysqld.service' '/etc/systemd/system/multi-user.target.wants/mysqld.service'<span class="Apple-converted-space"> </span><br />#systemctl start mysqld<span class="Apple-converted-space"> </span><br />#systemctl list-unit-files | grep mysql<span class="Apple-converted-space"> </span><br />mysql.service enabled<span class="Apple-converted-space"> </span><br />mysqld.service enabled</code></div>
</div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<span class="notranslate">現在,你應該是好去...</span></div>
</div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-72580909522068352272014-10-12T01:29:00.002+08:002014-10-12T01:29:18.156+08:00旋轉的MySQL慢日誌<div dir="ltr" style="text-align: left;" trbidi="on">
Original post: <a href="http://anothermysqldba.blogspot.com/2014/10/rotating-mysql-slow-logs.html">http://anothermysqldba.blogspot.com/2014/10/rotating-mysql-slow-logs.html</a><br />
<br />
<span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">同時與不同的客戶工作,我碰巧會遇到的非常大的慢日誌文件時有發生。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">雖然他們如何應該旋轉的若干意見存在。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">許多這些意見使用日誌旋轉和刷新日誌的命令,我不喜歡,雖然我刷新二進制日誌。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">這就是為什麼我同意羅納德·布拉德福德的<a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&tl=zh-TW&u=http://ronaldbradford.com/blog/the-correct-approach-to-rolling-mysql-logs-2010-02-22/&usg=ALkJrhgwJo0Q_gllFBrIE9cvTZnRMVFY2A" style="color: #888888; text-decoration: none;">博客文章</a><span class="Apple-converted-space"> </span>,從幾年前就如何做到這一點。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br />
<ul style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; margin: 0.5em 0px; orphans: auto; padding: 0px 2.5em; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<li style="margin: 0px 0px 0.25em; padding: 0px; text-indent: 0px;"><span class="notranslate"><a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&tl=zh-TW&u=http://ronaldbradford.com/blog/the-correct-approach-to-rolling-mysql-logs-2010-02-22/&usg=ALkJrhgwJo0Q_gllFBrIE9cvTZnRMVFY2A" style="color: #888888; text-decoration: none;">http://ronaldbradford.com/blog/the,正確的,方法對滾動MySQL的日誌- 2010-02-22/</a></span></li>
</ul>
<span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">我已經採取了它遠一點和腳本的步驟。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">在bash腳本是建立在MySQL 5.6和記mysql_config_editor它可以在舊版本的MySQL中被使用。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">該腳本將執行下列操作:</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><ul style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; margin: 0.5em 0px; orphans: auto; padding: 0px 2.5em; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<li style="margin: 0px 0px 0.25em; padding: 0px; text-indent: 0px;"><span class="notranslate">收集當前的日誌文件名</span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px; text-indent: 0px;"><span class="notranslate">收集當前的長查詢時間值</span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px; text-indent: 0px;"><span class="notranslate">復位長的查詢時間為更高的值</span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px; text-indent: 0px;"><span class="notranslate">不同的副本截斷它,以及日誌(參見羅納德的帖子)</span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px; text-indent: 0px;"><span class="notranslate">復位長查詢時間回到原來的時間</span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px; text-indent: 0px;"><span class="notranslate">執行,如果你想一個簡單的慢查詢,以便您可以檢查新的記錄速度慢</span></li>
<li style="margin: 0px 0px 0.25em; padding: 0px; text-indent: 0px;"><span class="notranslate">刪除舊的日誌慢,所以你可以得到的空間回來。</span></li>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px; text-indent: 0px;"><span class="notranslate">如果你希望查看的日誌,而不是你可以發表評論,此命令的。</span></li>
</ul>
</ul>
<span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">因此,所有這一切工作的?</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">好吧,讓我們用這個例子。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">我目前使用的mysql_config_editor超過.my.cnf文件,所以我相應地更新腳本。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"># mysql_config_editor print --all<span class="Apple-converted-space"> </span><br />[local]<span class="Apple-converted-space"> </span><br />user = root<span class="Apple-converted-space"> </span><br />password = *****<span class="Apple-converted-space"> </span><br />host = localhost<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">我可以看到,這個慢查詢日誌現在是1G。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"># ls -alh mysql-slow.log<span class="Apple-converted-space"> </span><br />-rw-rw---- 1 mysql mysql 1.1G Oct 11 16:08 mysql-slow.log<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">所以,我執行腳本</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"># /root/rotate_slow_logs.sh<span class="Apple-converted-space"> </span><br /># ls -alh mysql-slow.log<span class="Apple-converted-space"> </span><br />-rw-rw---- 1 mysql mysql 5.8K Oct 11 16:11 mysql-slow.log<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">好啊好啊,它的工作,我現在有一個更小的日誌文件,而無需刷新我的垃圾桶日誌或重新啟動MySQL的。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">該腳本可以被添加到一個crontab所以你可以經常你想旋轉。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">下面是該腳本。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;">#!/bin/bash<span class="Apple-converted-space"> </span><br /><br /># THIS IS BUILT WITH MYSQL 5.6 SECURITY IN MIND.<span class="Apple-converted-space"> </span><br /># SET THE LOGINPATHVALUE if you are using the mysql_config_editor<span class="Apple-converted-space"> </span><br /># IF YOU ARE NOT USING THE mysql_config_editor THEN IT IS ASSUMED YOU HAVE<span class="Apple-converted-space"> </span><br /># SET A .my.cnf FILE IN THE USER HOME DIR OR THIS USER HAS NO PASSWORD SET<span class="Apple-converted-space"> </span><br /><br /><br /># PLEASE SET THIS ACCORDINGLY TO YOUR SYSTEM.<span class="Apple-converted-space"> </span><br />LOGINPATHVALUE="local";<span class="Apple-converted-space"> </span><br /><br />if [ -z "${LOGINPATHVALUE}" ]; then<span class="Apple-converted-space"> </span><br />LOGINPATH="";<span class="Apple-converted-space"> </span><br />fi<span class="Apple-converted-space"> </span><br /><br />if [ -n "${LOGINPATHVALUE-unset}" ]; then<span class="Apple-converted-space"> </span><br />LOGINPATH="--login-path=$LOGINPATHVALUE "<span class="Apple-converted-space"> </span><br /><br />fi<span class="Apple-converted-space"> </span><br /><br /># GATHERS THE LOG FILE NAME<span class="Apple-converted-space"> </span><br />SLOWLOG=$(mysqladmin $LOGINPATH variables | grep slow | grep file | awk '/[a-zA-Z]/ {print $4}' )<span class="Apple-converted-space"> </span><br /><br /># GATHER CURRENT VALUE<span class="Apple-converted-space"> </span><br />LQT=$( mysqladmin $LOGINPATH variables | grep long_query_time | awk '/[0-9]./ {print $4}' )<span class="Apple-converted-space"> </span><br />LQTB=$(mysql $LOGINPATH -e " SELECT @@global.long_query_time *200 AS LQTB;" | awk '/[0-9]./ {print $1}' )<span class="Apple-converted-space"> </span><br />LQTC=$(mysql $LOGINPATH -e " SELECT @@global.long_query_time *2 AS LQTC;" | awk '/[0-9]./ {print $1}' )<span class="Apple-converted-space"> </span><br /><br /># GATHER MARKER<span class="Apple-converted-space"> </span><br />DATE=`date +"%m%d%Y"`<span class="Apple-converted-space"> </span><br /><br /># RESET SLOW QUERY TIME<span class="Apple-converted-space"> </span><br /># SET GLOBAL long_query_time=10;<span class="Apple-converted-space"> </span><br />mysql $LOGINPATH -e "SET GLOBAL long_query_time= $LQTB"<span class="Apple-converted-space"> </span><br /><br />LQTD=$( mysqladmin $LOGINPATH variables | grep long_query_time | awk '/[0-9]./ {print $4}' )<span class="Apple-converted-space"> </span><br /><br />#MOVE THE LOG OUT<span class="Apple-converted-space"> </span><br />cp $SLOWLOG $SLOWLOG.$DATE; > $SLOWLOG<span class="Apple-converted-space"> </span><br /><br />#SET THE TIMEBACK<span class="Apple-converted-space"> </span><br />mysql $LOGINPATH -e "SET GLOBAL long_query_time= $LQT"<span class="Apple-converted-space"> </span><br /><br />LQTD=$( mysqladmin $LOGINPATH variables | grep long_query_time | awk '/[0-9]./ {print $4}' )<span class="Apple-converted-space"> </span><br /><br />#PLACE A Slow query for log<span class="Apple-converted-space"> </span><br />SLOWQUERY=$(mysql $LOGINPATH -e "SELECT sleep($LQTC) " )<span class="Apple-converted-space"> </span><br /><br /># REMOVE OLD LOG<span class="Apple-converted-space"> </span><br />/bin/rm -f $SLOWLOG.$DATE;</code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.4799995422363px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /></div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-75781448702197940672014-09-24T10:50:00.000+08:002014-09-24T10:50:01.779+08:00MySQL的用戶連接<div dir="ltr" style="text-align: left;" trbidi="on">
<div>
<span class="notranslate">Original post:<a href="http://anothermysqldba.blogspot.com/2014/09/mysql-user-connections.html"> http://anothermysqldba.blogspot.com/2014/09/mysql-user-connections.html</a> </span></div>
<div>
<span class="notranslate"><br /></span></div>
<div>
<span class="notranslate">所以,我發現自己解釋與MySQL的用戶,以及他們如何進行身份驗證的差異。</span> <span class="notranslate">首先,這些信息是不是新的,但可以在這裡找到:</span> </div>
<div>
</div>
<ul>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=en&tl=zh-TW&u=http://dev.mysql.com/doc/refman/5.6/en/connection-access.html&usg=ALkJrhg1XjXSIvXUs-VrYjs_p6v3r6BEEA">http://dev.mysql.com/doc/refman/5.6/en/connection-access.html</a></span> </li>
</ul>
<div>
<span class="notranslate">我只展示一些真實世界的例子來說明這一點。</span> </div>
<div>
<br /></div>
<div>
<span class="notranslate"> MySQL使用的用戶名和登錄時,計算一個用戶的權限。</span> <span class="notranslate">這就是為什麼最好的做法是刪除匿名用戶。</span> </div>
<div>
<br /></div>
<div>
<span class="notranslate">在這個例子中,我將開始了與以下用戶</span> </div>
<div>
<br /></div>
<br />
<div class="codebox">
<code>
</code><br /><div>
<div>
<code>MariaDB [(none)]> select user , host from mysql.user;</code> </div>
<div>
<code>+---------+-----------+</code> </div>
<div>
<code>| user | host |</code> </div>
<div>
<code>+---------+-----------+</code> </div>
<div>
<code>| root | 127.0.0.1 |</code> </div>
<div>
<code>| root | ::1 |</code> </div>
<div>
<code>| | centos64 |</code> </div>
<div>
<code>| root | centos64 |</code> </div>
<div>
<code>| | localhost |</code> </div>
<div>
<code>| root | localhost |</code> </div>
<div>
<code>+---------+-----------+</code> </div>
</div>
<code>
</code></div>
<div>
<br /></div>
<div>
<span class="notranslate">我可以登錄到該服務器甚至認為我沒有用戶名,因為它的默認值降至匿名@本地。</span> </div>
<div>
<br /></div>
<div>
<div class="codebox">
<code>
</code><br /><div>
<code># mysql -u nobody</code> </div>
<div>
<div>
<span class="notranslate"> MariaDB [(無)]>選擇CURRENT_USER();</span> </div>
<div>
<span class="notranslate"> + ---------------- +</span> </div>
<div>
<span class="notranslate"> | CURRENT_USER()|</span> </div>
<div>
<span class="notranslate"> + ---------------- +</span> </div>
<div>
<span class="notranslate"> | @localhost |</span> </div>
<div>
<span class="notranslate"> + ---------------- +</span> </div>
</div>
<div>
<div>
<span class="notranslate"> MariaDB [(無)]>節目補助;</span> </div>
<div>
<span class="notranslate"> + -------------------------------------- +</span> </div>
<div>
<span class="notranslate"> |補助金@localhost |</span> </div>
<div>
<span class="notranslate"> + -------------------------------------- +</span> </div>
<div>
<span class="notranslate"> | GRANT USAGE ON * TO'@'localhost'的。|</span> </div>
<div>
<span class="notranslate"> + -------------------------------------- +</span> </div>
</div>
</div>
</div>
<div>
<br /></div>
<div>
<span class="notranslate">雖然我不能做很多我還有到數據庫中。</span> </div>
<div>
<br /></div>
<div>
<span class="notranslate">現在,當我通過一個已知的用戶:</span> </div>
<div>
<br /></div>
<div>
<div class="codebox">
<code>
</code><br /><div>
<code># mysql -u root -p</code> </div>
<div>
<div>
<span class="notranslate"> MariaDB [(無)]>選擇CURRENT_USER;</span> </div>
<div>
<span class="notranslate"> + ---------------- +</span> </div>
<div>
<span class="notranslate"> | CURRENT_USER |</span> </div>
<div>
<span class="notranslate"> + ---------------- +</span> </div>
<div>
<span class="notranslate"> |根@本地|</span> </div>
<div>
<span class="notranslate"> + ---------------- +</span> </div>
</div>
<div>
<div>
<span class="notranslate"> MariaDB [(無)]>節目補助;</span> </div>
<div>
+----------------------------------------------------------------------------------------------------------------------------------------+
</div>
<div>
<span class="notranslate"> |補助金根@本地|</span> </div>
<div>
+----------------------------------------------------------------------------------------------------------------------------------------+
</div>
<div>
<span class="notranslate"> |於授出日期所有特權* TO'根'@'localhost'的IDENTIFIED BY密碼“* 8CD56861FDADF7A264741F27D502D1A8DAE0A8F7'WITH GRANT OPTION。|</span> </div>
<div>
<span class="notranslate"> |授予代理開'@''到'根'@'localhost'的WITH GRANT OPTION |</span> </div>
<div>
+----------------------------------------------------------------------------------------------------------------------------------------+
</div>
</div>
</div>
</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<span class="notranslate">目前root用戶擁有4個不同的賬戶。</span> </div>
<div>
<div class="codebox">
<code>
</code><br /><div>
<div>
<code>MariaDB [(none)]> select user , host from mysql.user where user = 'root';</code> </div>
<div>
<code>+------+-----------+</code> </div>
<div>
<code>| user | host |</code> </div>
<div>
<code>+------+-----------+</code> </div>
<div>
<code>| root | 127.0.0.1 |</code> </div>
<div>
<code>| root | ::1 |</code> </div>
<div>
<code>| root | centos64 |</code> </div>
<div>
<code>| root | localhost |</code> </div>
<div>
<code>+------+-----------+</code> </div>
</div>
<code>
</code></div>
</div>
<div>
<br /></div>
<div>
<span class="notranslate">這些都是不同的賬戶。</span> <span class="notranslate">我只需要,雖然他們中的一個。</span> <span class="notranslate">我只通過本地主機連接使用root帳戶。</span> </div>
<div>
<div class="codebox">
<code>
</code><br /><div>
<div>
<code>MariaDB [(none)]> DROP USER 'root'@'127.0.0.1';</code> </div>
<div>
<code>Query OK, 0 rows affected (0.33 sec)</code> </div>
<div>
<code><br /></code> </div>
<div>
<code>MariaDB [(none)]> DROP USER 'root'@'centos64';</code> </div>
<div>
<code>Query OK, 0 rows affected (0.02 sec)</code> </div>
<div>
<code><br /></code> </div>
<div>
<code>MariaDB [(none)]> DROP USER 'root'@'::1';</code> </div>
<div>
<code>Query OK, 0 rows affected (0.00 sec)</code> </div>
<div>
<code><br /></code> </div>
<div>
<code>MariaDB [(none)]> select user , host from mysql.user where user = 'root';</code> </div>
<div>
<code>+------+-----------+</code> </div>
<div>
<code>| user | host |</code> </div>
<div>
<code>+------+-----------+</code> </div>
<div>
<code>| root | localhost |</code> </div>
<div>
<code>+------+-----------+</code> </div>
</div>
<code>
</code></div>
</div>
<div>
<br /></div>
<div>
<span class="notranslate">那麼,什麼沒我說的4種不同的帳戶嗎?</span> <span class="notranslate">他們都以root用戶帳戶。</span> <span class="notranslate">不..他們的根和任何主機。</span> <span class="notranslate">因此,每個帳戶(用戶+主機)可以有不同的權限。</span> </div>
<div>
<br /></div>
<div>
<span class="notranslate">所以我們將做一個例子旁邊,以示區別。</span> </div>
<div>
<span class="notranslate">所以在這個例子中,服務器有兩個網絡接口。</span> <span class="notranslate">因此,我將每創建的所有接入點各有不同的權限,以顯示不同的用戶。</span> <span class="notranslate">我會設置相同的密碼,但這些可能是不同的。</span> </div>
<div>
<div class="codebox">
<code>
</code><br /><div>
<div>
<code>MariaDB [(none)]> GRANT SELECT ON *.* TO 'anothermysqldba'@'10.0.2.15' IDENTIFIED BY '<cleartext password>';</code> </div>
<div>
<code>Query OK, 0 rows affected (0.01 sec)</code> </div>
<div>
<code><br /></code> </div>
<div>
<code>MariaDB
[(none)]> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE , DROP,
RELOAD, SHUTDOWN, PROCESS, FILE, INDEX, ALTER ON *.* TO
'anothermysqldba'@'192.168.0.%' IDENTIFIED BY '<cleartext
password>';</code> </div>
<div>
<code>Query OK, 0 rows affected (0.00 sec)</code> </div>
<div>
<code><br /></code> </div>
<div>
<code>MariaDB
[(none)]> GRANT ALL PRIVILEGES ON *.* TO
'anothermysqldba'@'localhost' IDENTIFIED BY '<cleartext
password>' WITH GRANT OPTION;</code> </div>
<div>
<code>Query OK, 0 rows affected (0.00 sec)</code> </div>
</div>
<div>
<br /></div>
<div>
<div>
<span class="notranslate"> MariaDB [(無)]>選擇用戶,從mysql.user其中user ='anothermysqldba“主持人;</span> </div>
<div>
<span class="notranslate"> + ----------------- + ------------- +</span> </div>
<div>
<span class="notranslate"> |用戶|主機|</span> </div>
<div>
<span class="notranslate"> + ----------------- + ------------- +</span> </div>
<div>
<span class="notranslate"> | anothermysqldba | 10.0.2.15 |</span> </div>
<div>
<span class="notranslate"> | anothermysqldba | 192.168.0。%|</span> </div>
<div>
<span class="notranslate"> | anothermysqldba |本地主機|</span> </div>
<div>
<span class="notranslate"> + ----------------- + ------------- +</span> </div>
</div>
</div>
</div>
<div>
<br /></div>
<div>
<span class="notranslate">所以,這是什麼意思?</span> <span class="notranslate">即使用戶名是相同的,因為MySQL使用主機以及驗證用戶的每用戶接入點的不同的權限。</span> </div>
<div>
<br /></div>
<div>
<span class="notranslate">雖然你可能會相信你的一些開發商,這往往是一個好主意,以限制他們的一些訪問,如果他們是遠程或通過他們的劇本工作。</span> <span class="notranslate">如果他們需要做的事情,不涉及你和他們有ssh到服務器本身並登錄到執行其他任務。</span> <span class="notranslate">當然,這是依賴於你的業務和/或應用程序之間的關係和工作流程。</span> </div>
<div>
<br /></div>
<div>
<span class="notranslate">使用10.0.2.15的主機,用戶只需選擇接入。</span> </div>
<div>
<div class="codebox">
<code>
</code><br /><div>
<code># mysql -h 10.0.2.15 -u anothermysqldba -p</code> </div>
<div>
<div>
<span class="notranslate"> MariaDB [(無)]>選擇CURRENT_USER();</span> </div>
<div>
<span class="notranslate"> + --------------------------- +</span> </div>
<div>
<span class="notranslate"> | CURRENT_USER()|</span> </div>
<div>
<span class="notranslate"> + --------------------------- +</span> </div>
<div>
<span class="notranslate"> | anothermysqldba@10.0.2.15 |</span> </div>
<div>
<span class="notranslate"> + --------------------------- +</span> </div>
</div>
<div>
<span class="notranslate"> MariaDB [(無)]>節目補助;</span> </div>
<div>
<div>
+-------------------------------------------------------------------------------------------------------------------------+ </div>
<div>
<span class="notranslate"> |補助金anothermysqldba@10.0.2.15 |</span> </div>
<div>
+-------------------------------------------------------------------------------------------------------------------------+ </div>
<div>
<span class="notranslate"> | GRANT SELECT ON * TO'anothermysqldba'@'10.0.2.15'IDENTIFIED BY密碼“* 31360D7EE84BE965C0E759179FC61B6943BCA64F”。|</span> </div>
<div>
+-------------------------------------------------------------------------------------------------------------------------+ </div>
</div>
</div>
</div>
<div>
<br /></div>
<div>
<span class="notranslate">使用192.168.0.26主機的用戶有更多的機會。</span> <span class="notranslate">此帳戶也設置192.168.0 / 255(%)子網下過任何訪問。</span> </div>
<div>
<div class="codebox">
<code>
</code><br /><div>
<code># mysql -h 192.168.0.26 -u anothermysqldba -p</code> </div>
<div>
<div>
<span class="notranslate"> MariaDB [(無)]>選擇CURRENT_USER();</span> </div>
<div>
<span class="notranslate"> + + -----------------------------</span> </div>
<div>
<span class="notranslate"> | CURRENT_USER()|</span> </div>
<div>
<span class="notranslate"> + + -----------------------------</span> </div>
<div>
<span class="notranslate"> | anothermysqldba@192.168.0.% |</span> </div>
<div>
<span class="notranslate"> + + -----------------------------</span> </div>
</div>
<div>
<div>
<span class="notranslate"> MariaDB [(無)]>節目補助;</span> </div>
<div>
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
</div>
<div>
<span class="notranslate"> |補助金anothermysqldba@192.168.0.% |</span> </div>
<div>
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
</div>
<div>
<span class="notranslate">
| GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,刷新,關閉,進程,文件,索引,ALTER ON
* TO'anothermysqldba'@'192.168.0.%'IDENTIFIED BY密碼“*
31360D7EE84BE965C0E759179FC61B6943BCA64F”。|</span> </div>
<div>
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
</div>
</div>
</div>
</div>
<div>
<br /></div>
<div>
<span class="notranslate">所以,當你將承擔本地主機用戶具有完全訪問權限的帳戶。</span> </div>
<div>
<div class="codebox">
<code>
</code><br /><div>
<code># mysql -u anothermysqldba -p</code> </div>
<div>
<div>
<span class="notranslate"> MariaDB [(無)]>選擇CURRENT_USER();</span> </div>
<div>
<span class="notranslate"> + --------------------------- +</span> </div>
<div>
<span class="notranslate"> | CURRENT_USER()|</span> </div>
<div>
<span class="notranslate"> + --------------------------- +</span> </div>
<div>
<span class="notranslate"> | anothermysqldba @本地|</span> </div>
<div>
<span class="notranslate"> + --------------------------- +</span> </div>
<div>
<span class="notranslate"> 1行(0.00秒)</span> </div>
<div>
<br /></div>
<div>
<span class="notranslate"> MariaDB [(無)]>節目補助;</span> </div>
<div>
+---------------------------------------------------------------------------------------------------------------------------------------------------+
</div>
<div>
<span class="notranslate"> |補助金anothermysqldba @本地|</span> </div>
<div>
+---------------------------------------------------------------------------------------------------------------------------------------------------+
</div>
<div>
<span class="notranslate"> |於授出日期所有特權* TO'anothermysqldba'@'localhost'的IDENTIFIED BY密碼“* 31360D7EE84BE965C0E759179FC61B6943BCA64F'WITH GRANT OPTION。|</span> </div>
<div>
+---------------------------------------------------------------------------------------------------------------------------------------------------+
</div>
</div>
</div>
</div>
<div>
<br /></div>
<div>
<span class="notranslate">現在,當我說這是去掉匿名用戶的最佳實踐之前。</span> <span class="notranslate">使用<a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=en&tl=zh-TW&u=http://dev.mysql.com/doc/refman/5.6/en/mysql-secure-installation.html&usg=ALkJrhjX4TWCxJokTnflnpDvbqWW2uhkuw">mysql_secure_installation</a>安裝將有助於他為好。</span> </div>
<div>
<br /></div>
<div>
<span class="notranslate">為什麼這很重要?</span> </div>
<div>
<div class="codebox">
<code>
</code><br /><div>
<code># mysql -u anothremysqldba -p</code> </div>
<div>
<div>
<span class="notranslate"> MariaDB [(無)]>選擇CURRENT_USER();</span> </div>
<div>
<span class="notranslate"> + ---------------- +</span> </div>
<div>
<span class="notranslate"> | CURRENT_USER()|</span> </div>
<div>
<span class="notranslate"> + ---------------- +</span> </div>
<div>
<span class="notranslate"> | @localhost |</span> </div>
<div>
<span class="notranslate"> + ---------------- +</span> </div>
<div>
<span class="notranslate"> 1行集(0.00</span> </div>
</div>
</div>
</div>
<div>
<br /></div>
<div>
<span class="notranslate">這個<b>簡單的</b>例子......以上,只是避免簡單的錯誤。</span> <span class="notranslate">一個錯字允許訪問數據庫,它不應該允許這樣。</span> </div>
<div>
<br /></div>
<div>
<span class="notranslate">所以除去,然後,然後再次測試。</span> </div>
<div>
<div class="codebox">
<code>
</code><br /><div>
<div>
<code>MariaDB [(none)]> DROP USER ''@'localhost';</code> </div>
<div>
<code>Query OK, 0 rows affected (0.01 sec)</code> </div>
<div>
<code><br /></code> </div>
<div>
<code>MariaDB [(none)]> DROP USER ''@'centos64';</code> </div>
<div>
<code>Query OK, 0 rows affected (0.00 sec)</code> </div>
</div>
<div>
<br /></div>
<div>
<div>
<span class="notranslate"> #mysql的-u anothremysqldba -p</span> </div>
<div>
<span class="notranslate">輸入密碼:</span> </div>
<div>
<span class="notranslate"> ERROR 1045(28000):拒絕訪問用戶anothremysqldba'@'localhost'的(使用密碼:是</span> </div>
</div>
</div>
</div>
<div>
<br /></div>
<div>
<span class="notranslate">如果你的數據庫創建與大多與%為主機名或嚴格的IP地址,並沒有通配符那麼這是什麼意思?</span> </div>
<div>
<br /></div>
<div>
<span class="notranslate">這將是你一個安全和業務決策。</span> <span class="notranslate">個人既不是在我看來一個有效的選項。</span> <span class="notranslate">只是一個通配符(%)允許一個強大的接入點,但如果防火牆發生故障,也開啟了訪問遠程網絡外的用戶。</span> <span class="notranslate">每個用戶嚴格的IP地址也是相當嚴格的,我認為,但它依賴於用戶。</span> <span class="notranslate">例如,即使已經複製我寧願仍然使用IP地址與%,即創建一個帳戶:192.168.0%。</span> <span class="notranslate"> IP地址不發生變化( <i>遠程用戶數據庫管理員往往沒有告訴連靜態的變化</i> ),這通常會導致人來給DBA擁有訪問故障的投訴。</span> </div>
<div>
<br /></div>
<div>
<span class="notranslate">我曾經跟一個人的有限的鎖定到一個靜態IP地址的每個用戶的訪問。</span> <span class="notranslate">此人必須不斷地改變GRANT語句。</span> <span class="notranslate">人們必須能夠很容易地和有效地工作,同時可以確保您的最終安全。</span> </div>
<div>
<br /></div>
<div>
<span class="notranslate">當然現在這是一個簡單的例子。</span> <span class="notranslate"> MySQL本身也提供了更多的身份驗證選項</span> <br /><br /><br /><ul>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=en&tl=zh-TW&u=http://dev.mysql.com/doc/refman/5.6/en/pluggable-authentication.html&usg=ALkJrhid8YYm-ziNAU5ei731CG5Ua1a70w">http://dev.mysql.com/doc/refman/5.6/en/pluggable-authentication.html</a></span> </li>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=en&tl=zh-TW&u=http://dev.mysql.com/doc/refman/5.6/en/pam-authentication-plugin.html&usg=ALkJrhjKbP50_UXNMzsSlNAciBlQ0H9NbQ">http://dev.mysql.com/doc/refman/5.6/en/pam認證,plugin.html</a></span> </li>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=en&tl=zh-TW&u=https://mariadb.com/blog/new-feature-pam-plugin-mariadb&usg=ALkJrhjYl0i4dNBHbwD_zdhVdCOE4UMWrQ">https://mariadb.com/blog/new特徵-PAM-插件-mariadb</a></span> </li>
<li> <span class="notranslate"> <a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=en&tl=zh-TW&u=https://mariadb.com/kb/en/mariadb/documentation/mariadb-plugins/pam-authentication-plugin/&usg=ALkJrhiGXR6zEbTZj7WaUjt9nRQvOEcM_g">https://mariadb.com/kb/en/mariadb/documentation/mariadb-plugins/pam認證,plugin/</a></span> </li>
</ul>
</div>
<div>
<br /></div>
</div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-83113925038074294482014-08-14T10:12:00.004+08:002014-08-14T10:12:58.784+08:00MySQL的外鍵例:錯誤1452<div dir="ltr" style="text-align: left;" trbidi="on">
Original post - <a href="http://anothermysqldba.blogspot.com/2014/08/mysql-foreign-keys-example-error-1452.html">http://anothermysqldba.blogspot.com/2014/08/mysql-foreign-keys-example-error-1452.html</a><br />
<br />
<span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">所以,我今天跑過的情況處理有更新的字段,但用戶無法這樣做,因為相關的外鍵約束的左右。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">這個博客帖子是一個簡單的例子,說明一個外鍵,以及如何,如果你有這樣做的更新。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">首先,讓我們創建一個簡單的表,並用隨機數據填充它。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br />
<div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />CREATE TABLE `table_w_code` (<span class="Apple-converted-space"> </span><br />`SOMECode` varchar(50) COLLATE utf8_unicode_ci NOT NULL,<span class="Apple-converted-space"> </span><br />`NameofCode` varchar(50) COLLATE utf8_unicode_ci NOT NULL,<span class="Apple-converted-space"> </span><br />PRIMARY KEY (`SOMECode`)<span class="Apple-converted-space"> </span><br />) ENGINE=InnoDB ;<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">現在,我們需要另外一個表,有綁在我們前面的表的外鍵。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />[anothermysqldba]> CREATE TABLE `table_with_fk` (<span class="Apple-converted-space"> </span><br />`SOMEID` varchar(50) COLLATE utf8_unicode_ci NOT NULL,<span class="Apple-converted-space"> </span><br />`SOMECode` varchar(50) COLLATE utf8_unicode_ci NOT NULL,<span class="Apple-converted-space"> </span><br />`Somemorefields` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL,<span class="Apple-converted-space"> </span><br />PRIMARY KEY (`SOMEID`,`SOMECode`),<span class="Apple-converted-space"> </span><br />KEY `FK_Patient_Facility` (`SOMECode`),<span class="Apple-converted-space"> </span><br />CONSTRAINT `FK_CODE` FOREIGN KEY (`SOMECode`) REFERENCES `table_w_code` (`SOMECode`) ON DELETE NO ACTION ON UPDATE NO ACTION<span class="Apple-converted-space"> </span><br />) ENGINE=InnoDB;<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">因此,讓我們填充一些隨機數據插入表中,所以我們可以嘗試更高更新它們。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">如果需要對隨機數之前的職位是<a href="https://translate.googleusercontent.com/translate_c?act=url&depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&tl=zh-TW&u=http://anothermysqldba.blogspot.com/2014/06/mysql-random-integers.html&usg=ALkJrhi7VFRzZ0yW_JoF3K-gi6lMwCUR8A" style="color: #888888; text-decoration: none;">在這裡</a></span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />[anothermysqldba]> SET @A = 3;<span class="Apple-converted-space"> </span><br />Query OK, 0 rows affected (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />[anothermysqldba]> SET @B = 15 - @A;<span class="Apple-converted-space"> </span><br />Query OK, 0 rows affected (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />[anothermysqldba]> SET @C = 16;<span class="Apple-converted-space"> </span><br />Query OK, 0 rows affected (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />[anothermysqldba]> SET @D = 25 - @C;<span class="Apple-converted-space"> </span><br />Query OK, 0 rows affected (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />[anothermysqldba]> INSERT INTO table_w_code VALUES<span class="Apple-converted-space"> </span><br />-> ( SUBSTR(md5(''),FLOOR( @A + (RAND() * @B )) , FLOOR( @C + (RAND() * @D )) ) , 'ABC' ) ,<span class="Apple-converted-space"> </span><br />-> ( SUBSTR(md5(''),FLOOR( @A + (RAND() * @B )) , FLOOR( @C + (RAND() * @D )) ) , 'DEF' ) ,<span class="Apple-converted-space"> </span><br />-> ( SUBSTR(md5(''),FLOOR( @A + (RAND() * @B )) , FLOOR( @C + (RAND() * @D )) ) , 'GHI' ) ,<span class="Apple-converted-space"> </span><br />-> ( SUBSTR(md5(''),FLOOR( @A + (RAND() * @B )) , FLOOR( @C + (RAND() * @D )) ) , 'JKL' ) ,<span class="Apple-converted-space"> </span><br />-> ( SUBSTR(md5(''),FLOOR( @A + (RAND() * @B )) , FLOOR( @C + (RAND() * @D )) ) , 'MNO' ) ,<span class="Apple-converted-space"> </span><br />-> ( SUBSTR(md5(''),FLOOR( @A + (RAND() * @B )) , FLOOR( @C + (RAND() * @D )) ) , 'PQR' ) ,<span class="Apple-converted-space"> </span><br />-> ( SUBSTR(md5(''),FLOOR( @A + (RAND() * @B )) , FLOOR( @C + (RAND() * @D )) ) , 'STU' ) ,<span class="Apple-converted-space"> </span><br />-> ( SUBSTR(md5(''),FLOOR( @A + (RAND() * @B )) , FLOOR( @C + (RAND() * @D )) ) , 'VWX' ) ,<span class="Apple-converted-space"> </span><br />-> ( SUBSTR(md5(''),FLOOR( @A + (RAND() * @B )) , FLOOR( @C + (RAND() * @D )) ) , 'YZ' ) ;<span class="Apple-converted-space"> </span><br />Query OK, 9 rows affected (0.05 sec)<span class="Apple-converted-space"> </span><br />Records: 9 Duplicates: 0 Warnings: 0<span class="Apple-converted-space"> </span><br /><br />[anothermysqldba]> SELECT * from table_w_code ORDER BY NameofCode;<span class="Apple-converted-space"> </span><br />+--------------------------+------------+<span class="Apple-converted-space"> </span><br />| SOMECode | NameofCode |<span class="Apple-converted-space"> </span><br />+--------------------------+------------+<span class="Apple-converted-space"> </span><br />| 204e9800998ecf8427e | ABC |<span class="Apple-converted-space"> </span><br />| f00b204e9800998e | DEF |<span class="Apple-converted-space"> </span><br />| 98f00b204e9800998ecf8427 | GHI |<span class="Apple-converted-space"> </span><br />| 98f00b204e9800998e | JKL |<span class="Apple-converted-space"> </span><br />| 1d8cd98f00b204e9800 | MNO |<span class="Apple-converted-space"> </span><br />| 1d8cd98f00b204e9800998ec | PQR |<span class="Apple-converted-space"> </span><br />| 0b204e9800998ecf8427e | STU |<span class="Apple-converted-space"> </span><br />| cd98f00b204e9800998ec | VWX |<span class="Apple-converted-space"> </span><br />| d98f00b204e9800998ecf842 | YZ |<span class="Apple-converted-space"> </span><br />+--------------------------+------------+<span class="Apple-converted-space"> </span><br />9 rows in set (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />[anothermysqldba]> SET @D = 2;<span class="Apple-converted-space"> </span><br />Query OK, 0 rows affected (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />[anothermysqldba]> SET @E = 25 - @D;<span class="Apple-converted-space"> </span><br />Query OK, 0 rows affected (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />[anothermysqldba]> INSERT INTO table_with_fk SELECT SUBSTR(md5(''),FLOOR( @D + (RAND() * @E ))), SOMECode , NameofCode FROM table_w_code;<span class="Apple-converted-space"> </span><br />Query OK, 9 rows affected (0.08 sec)<span class="Apple-converted-space"> </span><br />Records: 9 Duplicates: 0 Warnings: 0<span class="Apple-converted-space"> </span><br /><br />[anothermysqldba]> select * from table_with_fk ORDER BY Somemorefields;<span class="Apple-converted-space"> </span><br />+---------------------------------+--------------------------+----------------+<span class="Apple-converted-space"> </span><br />| SOMEID | SOMECode | Somemorefields |<span class="Apple-converted-space"> </span><br />+---------------------------------+--------------------------+----------------+<span class="Apple-converted-space"> </span><br />| 41d8cd98f00b204e9800998ecf8427e | 204e9800998ecf8427e | ABC |<span class="Apple-converted-space"> </span><br />| e9800998ecf8427e | f00b204e9800998e | DEF |<span class="Apple-converted-space"> </span><br />| 98ecf8427e | 98f00b204e9800998ecf8427 | GHI |<span class="Apple-converted-space"> </span><br />| 00b204e9800998ecf8427e | 98f00b204e9800998e | JKL |<span class="Apple-converted-space"> </span><br />| 04e9800998ecf8427e | 1d8cd98f00b204e9800 | MNO |<span class="Apple-converted-space"> </span><br />| 04e9800998ecf8427e | 1d8cd98f00b204e9800998ec | PQR |<span class="Apple-converted-space"> </span><br />| b204e9800998ecf8427e | 0b204e9800998ecf8427e | STU |<span class="Apple-converted-space"> </span><br />| b204e9800998ecf8427e | cd98f00b204e9800998ec | VWX |<span class="Apple-converted-space"> </span><br />| 4e9800998ecf8427e | d98f00b204e9800998ecf842 | YZ |<span class="Apple-converted-space"> </span><br />+---------------------------------+--------------------------+----------------+<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">確定這是一個四圍的方式來產生一些隨機的數據,這個例子。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">因此,如果我們需要更新與在table_with_fk農行值數據會發生什麼?</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />[anothermysqldba]> SELECT SOMEID , SOMECode , Somemorefields FROM table_with_fk WHERE Somemorefields = 'ABC';<span class="Apple-converted-space"> </span><br />+---------------------------------+---------------------+----------------+<span class="Apple-converted-space"> </span><br />| SOMEID | SOMECode | Somemorefields |<span class="Apple-converted-space"> </span><br />+---------------------------------+---------------------+----------------+<span class="Apple-converted-space"> </span><br />| 41d8cd98f00b204e9800998ecf8427e | 204e9800998ecf8427e | ABC |<span class="Apple-converted-space"> </span><br />+---------------------------------+---------------------+----------------+<span class="Apple-converted-space"> </span><br /><br />[anothermysqldba]> SELECT SOMECode , NameofCode FROM table_w_code WHERE NameofCode = 'ABC';<span class="Apple-converted-space"> </span><br />+---------------------+------------+<span class="Apple-converted-space"> </span><br />| SOMECode | NameofCode |<span class="Apple-converted-space"> </span><br />+---------------------+------------+<span class="Apple-converted-space"> </span><br />| 204e9800998ecf8427e | ABC |<span class="Apple-converted-space"> </span><br />+---------------------+------------+<span class="Apple-converted-space"> </span><br /><br />[anothermysqldba]><span class="Apple-converted-space"> </span><br />UPDATE table_with_fk SET SOMEID = 'I UPDATED THIS' , SOMECode = 'I UPDATED THIS' WHERE SOMECode = '204e9800998ecf8427e';<span class="Apple-converted-space"> </span><br /><b>ERROR 1452</b><span class="Apple-converted-space"> </span>(23000): Cannot add or update a child row:<span class="Apple-converted-space"> </span><b>a foreign key constraint fails</b>(`anothermysqldba`.`table_with_fk`, CONSTRAINT `FK_CODE` FOREIGN KEY (`SOMECode`) REFERENCES `table_w_code` (`SOMECode`) ON DELETE NO ACTION ON UPDATE NO ACTION)<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">因此,它被攔截喜歡它應有的水平。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">我們畢竟有“ON DELETE NO ACTION ON UPDATE NO ACTION”中的表定義。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">一切都沒有,雖然丟失。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">在“FOREIGN_KEY_CHECKS”變量的簡單的編輯將允許UPDATE語句來執行。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">然而,它是安全執行這一點,在我看來,在一個事務中。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;"><br />[anothermysqldba]> START TRANSACTION;<span class="Apple-converted-space"> </span><br />Query OK, 0 rows affected (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />[anothermysqldba]> SET FOREIGN_KEY_CHECKS=0;<span class="Apple-converted-space"> </span><br />Query OK, 0 rows affected (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />[anothermysqldba]> UPDATE table_with_fk SET SOMEID = 'I UPDATED THIS' , SOMECode = 'I UPDATED THIS' WHERE SOMECode = '204e9800998ecf8427e';<span class="Apple-converted-space"> </span><br />Query OK, 1 row affected (0.00 sec)<span class="Apple-converted-space"> </span><br />Rows matched: 1 Changed: 1 Warnings: 0<span class="Apple-converted-space"> </span><br /><br />[anothermysqldba]> SET FOREIGN_KEY_CHECKS=1;<span class="Apple-converted-space"> </span><br />Query OK, 0 rows affected (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />[anothermysqldba]> COMMIT;<span class="Apple-converted-space"> </span><br />Query OK, 0 rows affected (0.07 sec)<span class="Apple-converted-space"> </span></code></div>
<br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">現在整體的問題是,為什麼你要打破你已到位是有原因的設置外鍵的值?</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">這完全取決於你。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">今天發生的事情,不知怎的,一個值已插入的值插入數據庫多餘的空白。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">所以,我做了一個類似的交易,以更新和刪除空白。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">總體來說...這只是表明它可以做到的。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span></div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.comtag:blogger.com,1999:blog-4912428912976775537.post-56226021329368058722014-07-19T02:56:00.002+08:002014-07-19T02:56:15.709+08:00MySQL的secure_auth錯誤<div dir="ltr" style="text-align: left;" trbidi="on">
Original post: <a href="http://anothermysqldba.blogspot.com/2014/07/mysql-secureauth-error.html">http://anothermysqldba.blogspot.com/2014/07/mysql-secureauth-error.html</a><br />
<br />
<span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">我以前處理的secure_auth錯誤時,在此它阻止複製<a href="https://translate.googleusercontent.com/translate_c?depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&tl=zh-TW&u=http://anothermysqldba.blogspot.com/2013/09/mysql-access-and-replication-blocked-by.html&usg=ALkJrhj6y7fjjWRRPSQR_3GQptJ9FrfnbQ" style="color: #888888; text-decoration: none;">的博客文章</a><span class="Apple-converted-space"> </span>。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">不過,我想通通過MySQL的客戶端連接時,我會把這個博客帖子更一般的修復。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">這是MySQL 5.6之前的服務器。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><span class="notranslate" style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">所以,如果你得到一個secure_auth錯誤,當連接到MySQL下面的步驟應該清除此錯誤。</span><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" /><br />
<div class="codebox" style="-webkit-text-stroke-width: 0px; background-color: #eeeeff; border: 1px solid black; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18.479999542236328px; orphans: auto; overflow: auto; padding: 10px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 600px; word-spacing: 0px;">
<code style="font-size: 0.9em;">+---------------+-------------------------------------------+<span class="Apple-converted-space"> </span><br />| User | Password |<span class="Apple-converted-space"> </span><br />+---------------+-------------------------------------------+<span class="Apple-converted-space"> </span><br />| authdtestuser | 34d22ac342c35af2</code><span class="Apple-converted-space"> </span><span class="notranslate"><code style="font-size: 0.9em;">+---------------+-------------------------------------------+<span class="Apple-converted-space"> </span><br />| User | Password |<span class="Apple-converted-space"> </span><br />+---------------+-------------------------------------------+<span class="Apple-converted-space"> </span><br />| authdtestuser | 34d22ac342c35af2 | |+---------------+-------------------------------------------+<span class="Apple-converted-space"> </span><br /><br />SELECT @@session.old_passwords, @@global.old_passwords; +-------------------------+------------------------+<span class="Apple-converted-space"> </span><br />| @@session.old_passwords | @@global.old_passwords |<span class="Apple-converted-space"> </span><br />+-------------------------+------------------------+<span class="Apple-converted-space"> </span><br />| 1 | 1 |<span class="Apple-converted-space"> </span><br />+-------------------------+------------------------+<span class="Apple-converted-space"> </span><br /><br />mysql> SET @@session.old_passwords = 0; SET @@global.old_passwords=0;<span class="Apple-converted-space"> </span><br />Query OK, 0 rows affected (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />mysql> SELECT @@session.old_passwords, @@global.old_passwords;<span class="Apple-converted-space"> </span><br />+-------------------------+------------------------+<span class="Apple-converted-space"> </span><br />| @@session.old_passwords | @@global.old_passwords |<span class="Apple-converted-space"> </span><br />+-------------------------+------------------------+<span class="Apple-converted-space"> </span><br />| 0 | 0 |<span class="Apple-converted-space"> </span><br />+-------------------------+------------------------+<span class="Apple-converted-space"> </span><br />1 row in set (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />mysql> SET PASSWORD FOR 'authdtestuser'@'localhost' = PASSWORD('sshthisisasecret');<span class="Apple-converted-space"> </span><br />Query OK, 0 rows affected (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />mysql> select User , Password from mysql.user where User = 'authdtestuser';<span class="Apple-converted-space"> </span><br />+---------------+-------------------------------------------+<span class="Apple-converted-space"> </span><br />| User | Password |<span class="Apple-converted-space"> </span><br />+---------------+-------------------------------------------+<span class="Apple-converted-space"> </span><br />| authdtestuser | *E48BD8BF1B9F29459E5284AD158443B5B33B70E4 |<span class="Apple-converted-space"> </span><br />+---------------+-------------------------------------------+<span class="Apple-converted-space"> </span><br />1 row in set (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />mysql> SET @@session.old_passwords = 1; SET @@global.old_passwords=1;<span class="Apple-converted-space"> </span><br /><br />mysql> SELECT @@session.old_passwords, @@global.old_passwords;<span class="Apple-converted-space"> </span><br />+-------------------------+------------------------+<span class="Apple-converted-space"> </span><br />| @@session.old_passwords | @@global.old_passwords |<span class="Apple-converted-space"> </span><br />+-------------------------+------------------------+<span class="Apple-converted-space"> </span><br />| 1 | 1 |<span class="Apple-converted-space"> </span><br />+-------------------------+------------------------+<span class="Apple-converted-space"> </span><br />1 row in set (0.00 sec)<span class="Apple-converted-space"> </span></code></span><code style="font-size: 0.9em;">| |+---------------+-------------------------------------------+<span class="Apple-converted-space"> </span><br /><br />SELECT @@session.old_passwords, @@global.old_passwords; +-------------------------+------------------------+<span class="Apple-converted-space"> </span><br />| @@session.old_passwords | @@global.old_passwords |<span class="Apple-converted-space"> </span><br />+-------------------------+------------------------+<span class="Apple-converted-space"> </span><br />| 1 | 1 |<span class="Apple-converted-space"> </span><br />+-------------------------+------------------------+<span class="Apple-converted-space"> </span><br /><br />mysql> SET @@session.old_passwords = 0; SET @@global.old_passwords=0;<span class="Apple-converted-space"> </span><br />Query OK, 0 rows affected (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />mysql> SELECT @@session.old_passwords, @@global.old_passwords;<span class="Apple-converted-space"> </span><br />+-------------------------+------------------------+<span class="Apple-converted-space"> </span><br />| @@session.old_passwords | @@global.old_passwords |<span class="Apple-converted-space"> </span><br />+-------------------------+------------------------+<span class="Apple-converted-space"> </span><br />| 0 | 0 |<span class="Apple-converted-space"> </span><br />+-------------------------+------------------------+<span class="Apple-converted-space"> </span><br />1 row in set (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />mysql> SET PASSWORD FOR 'authdtestuser'@'localhost' = PASSWORD('sshthisisasecret');<span class="Apple-converted-space"> </span><br />Query OK, 0 rows affected (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />mysql> select User , Password from mysql.user where User = 'authdtestuser';<span class="Apple-converted-space"> </span><br />+---------------+-------------------------------------------+<span class="Apple-converted-space"> </span><br />| User | Password |<span class="Apple-converted-space"> </span><br />+---------------+-------------------------------------------+<span class="Apple-converted-space"> </span><br />| authdtestuser | *E48BD8BF1B9F29459E5284AD158443B5B33B70E4 |<span class="Apple-converted-space"> </span><br />+---------------+-------------------------------------------+<span class="Apple-converted-space"> </span><br />1 row in set (0.00 sec)<span class="Apple-converted-space"> </span><br /><br />mysql> SET @@session.old_passwords = 1; SET @@global.old_passwords=1;<span class="Apple-converted-space"> </span><br /><br />mysql> SELECT @@session.old_passwords, @@global.old_passwords;<span class="Apple-converted-space"> </span><br />+-------------------------+------------------------+<span class="Apple-converted-space"> </span><br />| @@session.old_passwords | @@global.old_passwords |<span class="Apple-converted-space"> </span><br />+-------------------------+------------------------+<span class="Apple-converted-space"> </span><br />| 1 | 1 |<span class="Apple-converted-space"> </span><br />+-------------------------+------------------------+<span class="Apple-converted-space"> </span><br />1 row in set (0.00 sec)<span class="Apple-converted-space"> </span></code></div>
</div>
Keith Larson ( anothermysqldba )http://www.blogger.com/profile/10894464761448543094noreply@blogger.com