
{"id":3058,"date":"2019-05-14T09:05:30","date_gmt":"2019-05-14T08:05:30","guid":{"rendered":"http:\/\/dasini.net\/blog\/?p=3058"},"modified":"2019-05-14T09:05:37","modified_gmt":"2019-05-14T08:05:37","slug":"check-constraints-in-mysql","status":"publish","type":"post","link":"https:\/\/dasini.net\/blog\/2019\/05\/14\/check-constraints-in-mysql\/","title":{"rendered":"CHECK constraints in MySQL"},"content":{"rendered":"\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/cloud_by_olivier_dasini_512x360.jpg\" alt=\"Above the clouds by Olivier DASINI\"\/><\/figure>\n\n\n\n<p>MySQL (really) supports <a rel=\"noreferrer noopener\" aria-label=\"CHECK CONSTRAINT (opens in a new tab)\" href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/create-table-check-constraints.html\" target=\"_blank\">CHECK CONSTRAINT<\/a> since version <a rel=\"noreferrer noopener\" aria-label=\"8.0.16 (opens in a new tab)\" href=\"https:\/\/dev.mysql.com\/downloads\/mysql\/\" target=\"_blank\">8.0.16<\/a>.<br>In this article I will show you 2 things: <\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>An elegant way to <u>simulate<\/u> check constraint in MySQL 5.7 &amp; 8.0.<\/li><li>How easy and convenient it is to use <strong>CHECK<\/strong> constraints starting from  MySQL 8.0.<strong>16<\/strong>.<\/li><\/ol>\n\n\n\n<p>Please note that this article is strongly inspired by <a rel=\"noreferrer noopener\" aria-label=\"Mablomy (opens in a new tab)\" href=\"http:\/\/mablomy.blogspot.com\/\" target=\"_blank\">Mablomy<\/a>&lsquo;s blog post: <a rel=\"noreferrer noopener\" aria-label=\"CHECK constraint for MySQL - NOT NULL on generated columns (opens in a new tab)\" href=\"http:\/\/mablomy.blogspot.com\/2016\/04\/check-constraint-for-mysql-not-null-on.html\" target=\"_blank\">CHECK constraint for MySQL &#8211; NOT NULL on generated columns<\/a>.<\/p>\n\n\n\n<p>I\u2019m using the optimized&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/hub.docker.com\/r\/mysql\/mysql-server\" target=\"_blank\">MySQL Server Docker images<\/a>, created, maintained and supported by the MySQL team at Oracle.<br>For clarity I chose MySQL 8.0.<strong>15<\/strong> for the check constraint hack and  obviously 8.0.<strong>16<\/strong> for the \u00ab\u00a0real\u00a0\u00bb check constraint implementation.<\/p>\n\n\n\n<p><br>Deployment of MySQL 8.0.15 &amp; MySQL 8.0.16:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ docker run --name=mysql-8.0.15 -e MYSQL_ROOT_PASSWORD=unsafe -d mysql\/mysql-server:8.0.15\n d4ce35e429e08bbf46a02729e6667458e2ed90ce94e7622f1342ecb6c0dfa009<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>$ docker run --name=mysql-8.0.16 -e MYSQL_ROOT_PASSWORD=unsafe -d mysql\/mysql-server:8.0.16\n d3b22dff1492fe6cb488a7f747e4709459974e79ae00b60eb0aee20546b68a0f<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><u>Note<\/u>:<\/p><p>Obviously using a password on the command line interface can be <strong>insecure<\/strong>. <\/p><p>Please read the best practices of <a rel=\"noreferrer noopener\" href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/linux-installation-docker.html\" target=\"_blank\">deploying MySQL on Linux with Docker<\/a>.<\/p><\/blockquote>\n\n\n\n\n\n<h2 class=\"wp-block-heading\">Example 1<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Check constraints hack<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>$ docker exec -it mysql-8.0.15 mysql -uroot -p --prompt='mysql-8.0.15> '\nEnter password: \n\nmysql-8.0.15> CREATE SCHEMA test;\nQuery OK, 1 row affected (0.03 sec)\n\nmysql-8.0.15> USE test\nDatabase changed\n\nmysql-8.0.15> SELECT VERSION();\n+-----------+\n| VERSION() |\n+-----------+\n| 8.0.15    |\n+-----------+\n\n\nmysql-8.0.15> \nCREATE TABLE checker_hack ( \n    i tinyint, \n    i_must_be_between_7_and_12 BOOLEAN \n         GENERATED ALWAYS AS (IF(i BETWEEN 7 AND 12, true, NULL)) \n         VIRTUAL NOT NULL\n);<\/code><\/pre>\n\n\n\n<p>As you can see, the trick is to use <a rel=\"noreferrer noopener\" aria-label=\"Generated Columns (opens in a new tab)\" href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/create-table-generated-columns.html\" target=\"_blank\">Generated Columns<\/a>, available since MySQL 5.7 and the flow control operator <a rel=\"noreferrer noopener\" aria-label=\"IF (opens in a new tab)\" href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/control-flow-functions.html#function_if\" target=\"_blank\">IF<\/a> where the check condition is put.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql-8.0.15> INSERT INTO checker_hack (i) VALUES (11);\nQuery OK, 1 row affected (0.03 sec)\n\nmysql-8.0.15> INSERT INTO checker_hack (i) VALUES (12);\nQuery OK, 1 row affected (0.01 sec)\n\n\nmysql-8.0.15> SELECT i FROM checker_hack;\n+------+\n| i    |\n+------+\n|   11 |\n|   12 |\n+------+\n2 rows in set (0.00 sec)<\/code><\/pre>\n\n\n\n<p>As expected, values that respect the condition (between 7 and 12) can be inserted.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql-8.0.15> INSERT INTO checker_hack (i) VALUES (13);\nERROR 1048 (23000): Column 'i_must_be_between_7_and_12' cannot be null\n\n\nmysql-8.0.15> SELECT i FROM checker_hack;\n+------+\n| i    |\n+------+\n|   11 |\n|   12 |\n+------+\n2 rows in set (0.00 sec)<\/code><\/pre>\n\n\n\n<p>Outside the limits, an error is raised.<br>We have our \u00ab\u00a0check constraint\u00a0\u00bb like feature \ud83d\ude42<\/p>\n\n\n\n\n\n<h3 class=\"wp-block-heading\">Check constraint since MySQL 8.0.16<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>$ docker exec -it mysql-8.0.16 mysql -uroot -p --prompt='mysql-8.0.16> '\nEnter password: \n\nmysql-8.0.16> CREATE SCHEMA test;\nQuery OK, 1 row affected (0.08 sec)\n\nmysql-8.0.16> USE test\nDatabase changed\n\nmysql-8.0.16> SELECT VERSION();\n+-----------+\n| VERSION() |\n+-----------+\n| 8.0.16    |\n+-----------+\n\n\nmysql-8.0.16> \nCREATE TABLE checker ( \n    i tinyint, \n    CONSTRAINT i_must_be_between_7_and_12 CHECK (i BETWEEN 7 AND 12 )\n);<\/code><\/pre>\n\n\n\n<p>Since MySQL 8.0.<strong>16<\/strong>, the CHECK keyword do the job. <br>I would recommend to name wisely your constraint.<br>The <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/create-table-check-constraints.html\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"syntax (opens in a new tab)\">syntax<\/a> is:<\/p>\n\n\n\n<p>[CONSTRAINT [symbol]] <strong>CHECK<\/strong> (expr) [[NOT] ENFORCED]<br><\/p>\n\n\n\n<p>From there, the following is rather obvious:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql-8.0.16> INSERT INTO checker (i) VALUES (11);\nQuery OK, 1 row affected (0.02 sec)\n\nmysql-8.0.16> INSERT INTO checker (i) VALUES (12);\nQuery OK, 1 row affected (0.03 sec)\n\n\nmysql-8.0.16> SELECT i FROM checker;\n+------+\n| i    |\n+------+\n|   11 |\n|   12 |\n+------+\n2 rows in set (0.00 sec)<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql-8.0.16> INSERT INTO checker (i) VALUES (13);\nERROR 3819 (HY000): Check constraint 'i_must_be_between_7_and_12' is violated.\n\n\nmysql-8.0.16> SELECT i FROM checker;\n+------+\n| i    |\n+------+\n|   11 |\n|   12 |\n+------+\n2 rows in set (0.00 sec)<\/code><\/pre>\n\n\n\n<p>Easy! \ud83d\ude42<\/p>\n\n\n\n\n\n<h2 class=\"wp-block-heading\" id=\"mce_19\">Example 2<\/h2>\n\n\n\n<p>You can check a combination of columns.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"mce_31\">Check constraints hack<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql-8.0.15> \nCREATE TABLE squares_hack (\n     dx DOUBLE, \n     dy DOUBLE, \n     area_must_be_larger_than_10 BOOLEAN \n           GENERATED ALWAYS AS (IF(dx*dy>10.0, true, NULL)) NOT NULL\n);\n\nmysql-8.0.15> INSERT INTO squares_hack (dx,dy) VALUES (7,4);\nQuery OK, 1 row affected (0.02 sec)\n\n\nmysql-8.0.15> INSERT INTO squares_hack (dx,dy) VALUES (2,4);\nERROR 1048 (23000): Column 'area_must_be_larger_than_10' cannot be null\n\n\nmysql-8.0.15> SELECT dx, dy FROM squares_hack;\n+------+------+\n| dx   | dy   |\n+------+------+\n|    7 |    4 |\n+------+------+\n1 row in set (0.00 sec)<\/code><\/pre>\n\n\n\n\n\n<h3 class=\"wp-block-heading\" id=\"mce_29\">Check constraint since MySQL 8.0.16<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql-8.0.16> \nCREATE TABLE squares (\n     dx DOUBLE, \n     dy DOUBLE, \n     CONSTRAINT area_must_be_larger_than_10 CHECK ( dx * dy > 10.0 )\n);\n\n\nmysql-8.0.16> INSERT INTO squares (dx,dy) VALUES (7,4);\nQuery OK, 1 row affected (0.01 sec)\n\n\nmysql-8.0.16> INSERT INTO squares (dx,dy) VALUES (2,4);\nERROR 3819 (HY000): Check constraint 'area_must_be_larger_than_10' is violated.\n\n\nmysql-8.0.16> SELECT dx, dy FROM squares;\n+------+------+\n| dx   | dy   |\n+------+------+\n|    7 |    4 |\n+------+------+\n1 row in set (0.00 sec)<\/code><\/pre>\n\n\n\n<p>Still easy!<\/p>\n\n\n\n\n\n<h2 class=\"wp-block-heading\" id=\"mce_19\">Example 3<\/h2>\n\n\n\n<p>You can also check text columns.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"mce_31\">Check constraints hack<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql-8.0.15> \nCREATE TABLE animal_hack (  \n     name varchar(30) NOT NULL,  \n     class varchar(100) DEFAULT NULL,  \n     class_allow_Mammal_Reptile_Amphibian BOOLEAN \n           GENERATED ALWAYS AS (IF(class IN (\"Mammal\", \"Reptile\", \"Amphibian\"), true, NULL)) NOT NULL\n);  \n\nmysql-8.0.15> INSERT INTO animal_hack (name, class) VALUES (\"Agalychnis callidryas\",'Amphibian');  \nQuery OK, 1 row affected (0.02 sec)\n\nmysql-8.0.15> INSERT INTO animal_hack (name, class) VALUES (\"Orycteropus afer\", 'Mammal');  \nQuery OK, 1 row affected (0.02 sec)\n\nmysql-8.0.15> INSERT INTO animal_hack (name, class) VALUES (\"Lacerta agilis\", 'Reptile');  \nQuery OK, 1 row affected (0.02 sec)\n\n\nmysql-8.0.15> SELECT name, class FROM animal_hack;\n+-----------------------+-----------+\n| name                  | class     |\n+-----------------------+-----------+\n| Agalychnis callidryas | Amphibian |\n| Orycteropus afer      | Mammal    |\n| Lacerta agilis        | Reptile   |\n+-----------------------+-----------+\n3 rows in set (0.00 sec)<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql-8.0.15> INSERT INTO animal_hack (name, class) VALUES (\"Palystes castaneus\", 'Arachnid'); \nERROR 1048 (23000): Column 'class_allow_Mammal_Reptile_Amphibian' cannot be null\n\n\nmysql-8.0.15> SELECT name, class FROM animal_hack;\n+-----------------------+-----------+\n| name                  | class     |\n+-----------------------+-----------+\n| Agalychnis callidryas | Amphibian |\n| Orycteropus afer      | Mammal    |\n| Lacerta agilis        | Reptile   |\n+-----------------------+-----------+\n3 rows in set (0.00 sec)<\/code><\/pre>\n\n\n\n\n\n<h3 class=\"wp-block-heading\" id=\"mce_45\">Check constraint since MySQL 8.0.16<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql-8.0.16> \nCREATE TABLE animal (  \n     name varchar(30) NOT NULL,  \n     class varchar(100) DEFAULT NULL,  \n     CONSTRAINT CHECK (class IN (\"Mammal\", \"Reptile\", \"Amphibian\"))\n);  \n\nmysql-8.0.16> INSERT INTO animal (name, class) VALUES (\"Agalychnis callidryas\",'Amphibian');  \nQuery OK, 1 row affected (0.04 sec)\n\nmysql-8.0.16> INSERT INTO animal (name, class) VALUES (\"Orycteropus afer\", 'Mammal');  \nQuery OK, 1 row affected (0.04 sec)\n\nmysql-8.0.16> INSERT INTO animal (name, class) VALUES (\"Lacerta agilis\", 'Reptile');  \nQuery OK, 1 row affected (0.04 sec)\n\n\nmysql-8.0.16> SELECT name, class FROM animal_hack;\n+-----------------------+-----------+\n| name                  | class     |\n+-----------------------+-----------+\n| Agalychnis callidryas | Amphibian |\n| Orycteropus afer      | Mammal    |\n| Lacerta agilis        | Reptile   |\n+-----------------------+-----------+\n3 rows in set (0.00 sec)<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql-8.0.16> INSERT INTO animal (name, class) VALUES (\"Palystes castaneus\", 'Arachnid');  \nERROR 3819 (HY000): Check constraint 'animal_chk_1' is violated.\n\n\nmysql-8.0.16> SELECT name, class FROM animal_hack;\n+-----------------------+-----------+\n| name                  | class     |\n+-----------------------+-----------+\n| Agalychnis callidryas | Amphibian |\n| Orycteropus afer      | Mammal    |\n| Lacerta agilis        | Reptile   |\n+-----------------------+-----------+\n3 rows in set (0.00 sec)<\/code><\/pre>\n\n\n\n<p>Frankly easy!<\/p>\n\n\n\n<p>I did not mention that the hack works as well in 8.0.16, though not needed anymore.<\/p>\n\n\n\n\n\n<p>CHECK constraint is another useful feature implemented in MySQL (and not the last one, stay tuned!). <br>There are some <a href=\"https:\/\/mysqlserverteam.com\/mysql-8-0-16-introducing-check-constraint\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"other interesting things (opens in a new tab)\">other interesting things<\/a> to know about this feature but also about the others available in <a rel=\"noreferrer noopener\" aria-label=\"MySQL 8.0.16 (opens in a new tab)\" href=\"https:\/\/mysqlserverteam.com\/the-mysql-8-0-16-maintenance-release-is-generally-available\/\" target=\"_blank\">MySQL 8.0.16<\/a>. <br>Please have a look on the references below.<\/p>\n\n\n\n\n\n<h2 class=\"wp-block-heading\" id=\"mce_0\">References<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a rel=\"noreferrer noopener\" aria-label=\"MySQL Documentation: CHECK Constraints (opens in a new tab)\" href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/create-table-check-constraints.html\" target=\"_blank\">MySQL Documentation: CHECK Constraints<\/a> <\/li><li><a rel=\"noreferrer noopener\" aria-label=\"WL#929: CHECK constraints (opens in a new tab)\" href=\"https:\/\/dev.mysql.com\/worklog\/task\/?id=929\" target=\"_blank\">WL#929: CHECK constraints<\/a> <\/li><li><a rel=\"noreferrer noopener\" aria-label=\"MySQL 8.0.16 Introducing CHECK constraint (opens in a new tab)\" href=\"https:\/\/mysqlserverteam.com\/mysql-8-0-16-introducing-check-constraint\/\" target=\"_blank\">MySQL 8.0.16 Introducing CHECK constraint<\/a> <\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/elephantdolphin.blogspot.com\/2019\/04\/mysql-8016-check-constraints.html\" target=\"_blank\">(Dave Stokes) &#8211; MySQL 8.0.16 Check Constraints<\/a> <\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/lefred.be\/content\/mysql-8-0-16-how-to-validate-json-values-in-nosql-with-check-constraint\/\" target=\"_blank\">(Lefred) &#8211; MySQL 8.0.16: how to validate JSON values in NoSQL with check constraint<\/a> <\/li><li><a rel=\"noreferrer noopener\" aria-label=\"(Mablomy) - CHECK constraint for MySQL - NOT NULL on generated columns (opens in a new tab)\" href=\"http:\/\/mablomy.blogspot.com\/2016\/04\/check-constraint-for-mysql-not-null-on.html\" target=\"_blank\">(Mablomy) &#8211; CHECK constraint for MySQL &#8211; NOT NULL on generated columns<\/a> <\/li><li><a href=\"https:\/\/yoku0825.blogspot.com\/2015\/08\/an-idea-for-using-mysql-57s-generated.html\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"An idea for using MySQL 5.7's generated column like CHECK constraint (opens in a new tab)\">An idea for using MySQL 5.7&rsquo;s generated column like CHECK constraint<\/a> <\/li><li><a rel=\"noreferrer noopener\" aria-label=\"The MySQL 8.0.16 Maintenance Release is Generally Available (opens in a new tab)\" href=\"https:\/\/mysqlserverteam.com\/the-mysql-8-0-16-maintenance-release-is-generally-available\/\" target=\"_blank\">The MySQL 8.0.16 Maintenance Release is Generally Available<\/a> <\/li><\/ul>\n\n\n\n\n\n<div style=\"height:75px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\"><strong>Thanks for using MySQL!<\/strong><\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><a href=\"https:\/\/www.linkedin.com\/groups\/12524512\/\" target=\"_blank\" rel=\"noopener\" title=\"Olivier DASINI on Linkedin\">Follow me on Linkedin<\/a><\/p>\n\n\n\n<p>Watch my videos on my <a href=\"https:\/\/www.youtube.com\/channel\/UC12TulyJsJZHoCmby3Nm3WQ\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"Olivier's MySQL Channel\">YouTube channel<\/a> and <a href=\"https:\/\/www.youtube.com\/channel\/UC12TulyJsJZHoCmby3Nm3WQ\/?sub_confirmation=1\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"Subscribe\">subscribe<\/a>.<\/p>\n\n\n\n<p>My <a href=\"https:\/\/www.slideshare.net\/freshdaz\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"Olivier DASINI on Slideshare\">Slideshare account<\/a>.<\/p>\n\n\n\n<p>My <a href=\"https:\/\/speakerdeck.com\/freshdaz\/\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"Olivier DASINI on Speaker Deck\">Speaker Deck account<\/a>.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\"><strong>Thanks for using HeatWave &amp; MySQL!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL (really) supports CHECK CONSTRAINT since version 8.0.16.<br \/>\nIn this article I will show you 2 things:<br \/>\n   &#8211; An elegant way to simulate check constraint in MySQL 5.7 &#038; 8.0.<br \/>\n   &#8211; How easy &#038; convenient it is to use CHECK constraints in 8.0.16.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"categories":[88,203],"tags":[935,936,308],"class_list":["post-3058","post","type-post","status-publish","format-standard","hentry","category-astuce","category-mysql-en","tag-check","tag-constraint","tag-generated-column-en"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9LfWW-Nk","jetpack-related-posts":[{"id":3157,"url":"https:\/\/dasini.net\/blog\/2019\/06\/05\/mysql-8-0-16-new-features-summary\/","url_meta":{"origin":3058,"position":0},"title":"MySQL 8.0.16 New Features Summary","author":"Olivier DASINI","date":"5 juin 2019","format":false,"excerpt":"Presentation of some of the new features of MySQL 8.0.16 released on April 25, 2019","rel":"","context":"Dans &quot;Group Replication&quot;","block_context":{"text":"Group Replication","link":"https:\/\/dasini.net\/blog\/category\/group-replication-en\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/img.youtube.com\/vi\/3_esLnhHHck\/0.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3166,"url":"https:\/\/dasini.net\/blog\/2019\/06\/11\/check-the-mysql-server-startup-configuration\/","url_meta":{"origin":3058,"position":1},"title":"Check the MySQL server startup configuration","author":"Olivier DASINI","date":"11 juin 2019","format":false,"excerpt":"Since 8.0.16, MySQL Server supports a --validate-config option that enables the startup configuration to be checked for problems without running the server in normal operational mode. --validate-config can be used any time, but is particularly useful after an upgrade, to check whether any options previously used with the older server\u2026","rel":"","context":"Dans &quot;Astuce&quot;","block_context":{"text":"Astuce","link":"https:\/\/dasini.net\/blog\/category\/astuce\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2746,"url":"https:\/\/dasini.net\/blog\/2019\/03\/14\/mysql-functional-indexes\/","url_meta":{"origin":3058,"position":2},"title":"MySQL Functional Indexes","author":"Olivier DASINI","date":"14 mars 2019","format":false,"excerpt":"Since MySQL 5.7 one can put indexes on expressions, aka functional indexes, using generated columns. Basically you first need to use the generated column to define the functional expression, then indexed this column. Quite useful when dealing with JSON functions, you can find an example here and the documentation there.\u2026","rel":"","context":"Dans &quot;Astuce&quot;","block_context":{"text":"Astuce","link":"https:\/\/dasini.net\/blog\/category\/astuce\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3219,"url":"https:\/\/dasini.net\/blog\/2019\/07\/11\/mysql-innodb-cluster-recovering-and-provisioning-with-mysql-enterprise-backup\/","url_meta":{"origin":3058,"position":3},"title":"MySQL InnoDB Cluster &#8211; Recovering and provisioning with MySQL Enterprise Backup","author":"Olivier DASINI","date":"11 juillet 2019","format":false,"excerpt":"Like I stated in my previous article - MySQL InnoDB Cluster - Recovering and provisioning with mysqldump : \"As the administrator of a cluster, among others tasks, you should be able to restore failed nodes and to add (or remove) new nodes\". Well, I still agree with myself :) MySQL\u2026","rel":"","context":"Dans &quot;Group Replication&quot;","block_context":{"text":"Group Replication","link":"https:\/\/dasini.net\/blog\/category\/group-replication-en\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3193,"url":"https:\/\/dasini.net\/blog\/2019\/07\/09\/mysql-innodb-cluster-recovering-and-provisioning-with-mysqldump\/","url_meta":{"origin":3058,"position":4},"title":"MySQL InnoDB Cluster &#8211;  Recovering and provisioning with mysqldump","author":"Olivier DASINI","date":"9 juillet 2019","format":false,"excerpt":"As the administrator of a cluster, among other tasks, you should be able to restore failed nodes and grow (or shrink) your cluster by adding (or removing) new nodes. In MySQL, as a backup tool (and if your amount of data is not too big), you can use mysqldump a\u2026","rel":"","context":"Dans &quot;Group Replication&quot;","block_context":{"text":"Group Replication","link":"https:\/\/dasini.net\/blog\/category\/group-replication-en\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2136,"url":"https:\/\/dasini.net\/blog\/2018\/03\/01\/mysql-security-password-validation-plugin\/","url_meta":{"origin":3058,"position":5},"title":"MySQL Security \u2013 Password Validation Plugin","author":"Olivier DASINI","date":"1 mars 2018","format":false,"excerpt":"In this article, 1st of a MySQL 5.7 Security series, we will see how to enforce Strong Passwords with Password Validation Plugin when using MySQL 5.7. Authentication with ID and password is a very simple and common (because it\u2019s simple) way to secure the access to a resource, however the\u2026","rel":"","context":"Dans &quot;MySQL&quot;","block_context":{"text":"MySQL","link":"https:\/\/dasini.net\/blog\/category\/mysql-en\/"},"img":{"alt_text":"MySQL Security","src":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/MySQL_DB_Lock2.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts\/3058","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/comments?post=3058"}],"version-history":[{"count":26,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts\/3058\/revisions"}],"predecessor-version":[{"id":3116,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts\/3058\/revisions\/3116"}],"wp:attachment":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/media?parent=3058"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/categories?post=3058"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/tags?post=3058"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}