2017/10/08 phpcon 2017 https://joind.in/event/japan-php-conference-2017/session05-mysqlRead less
ãã«ã¹ã¿ãã¯éçºè ã«æ±ããã¹ãã«ã¯æ代ã¨ã¨ãã«å¤ãã£ã¦ãã¾ãã2017å¹´ã®ãã«ã¹ã¿ãã¯éçºè ãåä¹ããªãæä½éç¥ã£ã¦ããã¹ãæè¡ã¨ç¥èãã¾ã¨ãã¾ããã ãããã¿ã¤ãããå®å ¨ãªMVPï¼Minimum Viable Productï¼å®ç¨æå°éã®ãããã¯ãï¼ã¾ã§ã«ãã¼ãããã«ã¹ã¿ãã¯éçºè ã®ãã¨ããå¤è¸ã¯ç¡è¸ãã¨è©ä¾¡ãã人ããã¾ãããããªä¸é¢ãããã§ããããã¾ãã¯ããã«ã¹ã¿ãã¯éçºè ãç¥ãããã«ãæ´å²ãæ¯ãè¿ãã¾ãã 以åã®ãã«ã¹ã¿ãã¯éçºè 2000å¹´ããï¼ã¤ã³ã¿ã¼ãããã§ã®17å¹´åã¯å¤§æã§ãï¼ã®ãã«ã¹ã¿ãã¯éçºè ã®å®ç¾©ã¯ãããªæãã§ããã PhotoshopãFireworksãªã©Adobeç³»ãã¼ã«ã§Webãã¼ã¸ãææ©ãä½ã ãã¶ã¤ã³ãHTMLãCSSã«å¤æããç»åã«ãããã¹ãããã追å ããï¼ãã¯ãå¿å´ã®ããªãã§ããï¼ï¼ ç°¡åãªPHP4.0ã¹ã¯ãªããï¼å½æã®PHPã¯ãªãã¸ã§ã¯ãæåã¨ã¯ç¡ç¸ï¼
MySQLãèµ·åãããã¨ããã¨ã次ã®ããã«ãªãã èµ·åã¯æåãããããNo directory, logging in with HOME=/ãã¨ããã¡ãã»ã¼ã¸ãã§ã¦ããã root@ubuntu:~# /etc/init.d/mysql start No directory, logging in with HOME=/ ...... * MySQL Community Server 5.6.20 is started ãã°ã¤ã³ããéã®HOMEãã£ã¬ã¯ããªãç¡ããã¨ãæå³ããã¡ãã»ã¼ã¸ã®ããã«è¦ããã ããã¯ä¸ä½èª°ã®HOMEãã£ã¬ã¯ããªãç¡ãã¨ãã£ã¦ããã®ãï¼rootã§èµ·åãå®è¡ãã¦ããã®ã§ãrootã ãããï¼ ã¾ããrootã®HOMEãã£ã¬ã¯ããªã確èªããã root@ubuntu:~# cat /etc/passwd | grep root root:x:0:0:root:/root
MySQL5.7ã«ããã¦ãJSON(JavaScript Object Notation)ããµãã¼ãããã¦ãã¦ã æ§ã ãªè¨èªãã¢ããªéã§ãããç°¡åã«ãã¼ã¿ã®åã渡ããè¡ããããã«ãªãã¾ããã ããã¥ã¡ã³ããJSONãã©ã¼ãããã§ãã¼ã¿ãã¼ã¹ã«ä¿åãã¦ã æ§ã ãªã¢ããªã±ã¼ã·ã§ã³ããå¼ã³åºãã¦å©ç¨åºæ¥ããªã©ã æ±ç¨æ§ã¨éç¨é¢ã§ã®æ´»ç¨ãåºæ¥ãããã«ãªã£ã¦ãã¾ãã 1) ãã¤ãã£ãã®JSONãã¼ã¿å å¹ççãªãã¼ã¿å¦çã¨ä¿ç®¡ã«ãã¤ãã£ãå é¨ãã¤ããªå½¢å¼ããµãã¼ãã 2) çµã¿è¾¼ã¿JSONãã¡ã³ã¯ã·ã§ã³ å¹çããããã¥ã¡ã³ããä¿å,æ¤ç´¢,æ´æ°,æä½ããäºãå¯è½ã«ãã¾ãã 3) JSON ã³ã³ãã¬ã¼ã¿ã¼ ææ¸ãã¼ã¿ã容æã«SQLã¯ã¨ãªã¨çµ±åãããã¨ãå¯è½ 4) Generated Columnsãå©ç¨ããããã¥ã¡ã³ãã«ã¤ã³ããã¯ã¹ãå©ç¨ããäºãå¯è½ã æ°ããã¢ãã©ã¤ã¶ã¼ã¯,èªåçã«å©ç¨å¯è½ã§æé©ãªæ©è½
JavaScriptã¨MySQLãã¤ãªããããããNode.jsãªããã #åç½®ã node.jså§ãã¦3æ¥ç®ç¨åº¦ã®ç¥èã§æ¸ãã¦ãã¾ãã ã¾ããMySQLããããªã«è©³ããããã§ã¯ãªãã§ãã ãã®è¨äºã¯æ¬å®¶ã®ããã¥ã¡ã³ããå ã«ä½æãã¾ããã ã³ã¼ããã»ã¼æ¬å®¶ã®ã³ããã§ãã ééãçããã¾ãããã³ã¡ã³ãã§ãããã¦ãã ããã ããã§ã¯node-mysqlã使ãã¾ãã #ã¤ã³ã¹ãã¼ã« npm install mysql #ã³ãã¯ã·ã§ã³ var mysql = require('mysql'); var connection = mysql.createConnection({ host : 'localhost', user : 'me', password : 'secret' }); //ããã¯çç¥ãã¦ãoKã connection.connect();
MySQLã使ã£ãã¢ããªã±ã¼ã·ã§ã³ãä½ãã¨ã³ã¸ãã¢ãç¥ãã¹ãMySQLã®å é¨æ§é ã«ã¤ãã¦ããã¼ã¿ãã¼ã¹ã³ã³ãµã«ãã£ã³ã°ä¼ç¤¾PalominoDBãçµå¶ããLaine Campbellæ°ã«ããåçãMySQLãç¥ãããã«ã¯ä½ããã¤ã³ãã«å¦ç¿ããã°ããã®ããããããããDBAãéçºè ã«ã¨ã£ã¦ãå½¹ç«ã¤å 容ã 1. ã¹ãã¬ã¼ã¸ã¨ã³ã¸ã³ ã¹ãã¬ã¼ã¸ã¨ã³ã¸ã³ã¨ãæ°¸ç¶æ§ãããã¯æ©æ§ããã©ã³ã¶ã¯ã·ã§ã³å¦çã®æ¯ãèããåé¢ã¬ãã«ã¨ãã£ãã¹ãã¬ã¼ã¸ã¨ã³ã¸ã³ã®åºç¤ã¨ãªãåãã«ã¤ãã¦ã®ç解ãªãã«ãMySQLèªä½ãã¢ãã«ãã¼ã¿ã®ã³ã¼ãããããã¹ãã§ãªããããã«å ãã¦ãInnoDBã®ã¯ã©ã¹ã¿åããããã©ã¤ããªãã¼ããMyISAMã®å ¨ææ¤ç´¢ã¤ã³ããã¯ã¹ã®ãããªã³ã¢è¦ç´ ãã極ãã¦éè¦ãªæ å ±ã ã 2. ã¤ã³ããã¯ã¹ã®ã³ã³ã»ãã ç¹ã«ä»¥ä¸ã®ãããªç¹ã«ã¤ãã¦ã ã«ããªã³ã°ã¤ã³ããã¯ã¹ é£çµã¤ã³ããã¯ã¹ ã¤ã³ããã¯ã¹ã使ã£ãã½ã¼ã
ããã§ã¯ãMySQLã®æ¨©éã·ã¹ãã ã詳ãã説æãã¦ãã¾ããè¨å®ã®ä»æ¹ã¯ãæ¥ç¶ã®æ¿èªããåç §ãã ããã MySQLç¹æ¨©ã·ã¹ãã æ¦è¦ MySQLã«ã¯ããã¼ã¿ãã¼ã¹ããã¹ããã¦ã¼ã¶ããã¼ãã«ããã£ã¼ã«ãæ¯ã«ããã¼ã¿ãã¼ã¹ãæä½ï¼é²è¦§ãæ¿å ¥ãæ´æ°ãåé¤ãªã©ï¼ããããã®æ§ã ãªæ¨©éãè¨å®ãããã¨ãã§ãã¾ãã MySQLã§ã¯ããã¼ã¿ãã¼ã¹ã«ã¢ã¯ã»ã¹ã§ããã¦ã¼ã¶/ãã¹ã¯ã¼ã/ãã¹ãåãmysqlã¨ãããã¼ã¿ãã¼ã¹ã«ç»é²ãã¦ããã®ã§ããã®ãã¼ã¿ãã¼ã¹ãè¨å®ãã¦ãããã¨ã«ãªãã¾ãã mysqlãã¼ã¿ãã¼ã¹ã«ç¨æããã¦ãã管çç¨ãã¼ãã«ã¯ãdbãhostãuserãtables_privãcolumns_privã®5ã¤ã§ãããã«ãããã©ã®ã¦ã¼ã¶ãã©ã®ãã¹ãããã®ä½ã®ãã¼ã¿ãã¼ã¹ã«å¯¾ãã¦ã¢ã¯ã»ã¹ã§ãããæå®ã§ãã¾ãã mysqlãã¼ã¿ãã¼ã¹å ã®ãã¼ãã«ä¸è¦§ ãã¼ã¿ãã¼ã¹å 説æ
å¹³ç´ ããQAï¼ ITããå©ç¨ããã ããèª ã«ãããã¨ããããã¾ãã QAï¼ ITã¯ã質åãåçããå ±æãããç·¨éããã¦ãããã¨ã§ãã¹ããªQAãèç©ã§ãããITã¨ã³ã¸ãã¢ã®ããã®åé¡è§£æ±ºã³ãã¥ããã£ã¼ãã¨ãã¦ç´7å¹´ééå¶ããã¦ãã¾ãããããã¾ã§ãµã¼ãã¹ãç¶ãããã¨ãã§ããã®ã¯ãQAï¼ ITã®ã³ã³ã»ããã«å ±æãããã ããé©åãªè³ªåãåçããå¯ãããã ããçãã¾ã®ãæ¯æ´ããã£ãããããã¨èãã¦ããã¾ããéãã¦å¾¡ç¤¼ç³ãä¸ãã¾ãã ããããªãããã¨ã³ã¸ãã¢ã®æ å ±å ¥ææ¹æ³ã®å¤æ§åãQAãµã¼ãã¹å¸å ´ã®ç¶æ³ãï¼ ITã®ä»å¾ã®ã¡ãã£ã¢éå¶æ¹éãªã©ãæ¤è¨ããçµæã2020å¹´2æ28æ¥ï¼éï¼15:00ããã¡ã¾ãã¦QAï¼ ITã®ãµã¼ãã¹ãçµäºãããã¨ã«ãã¾ããã ããã¾ã§ãå©ç¨ãããã ãã¾ããçãã¾ã«ã¯æ®å¿µãªãç¥ããã¨ãªããèª ã«å¿è¦ããæã£ã¦ããã¾ããä½ã¨ãããç解ãããã ãã¾ãã¨å¹¸ãã§ãã QAï¼ ITã®7å¹´éã§çãã¾ã®ç¥è
ç±³ãªã©ã¯ã«ã¯ããªã¼ãã³ã½ã¼ã¹ã®ãã¼ã¿ãã¼ã¹ã¨ãã¦æ®åãã¦ããMySQLãã¯ã©ã¹ã¿åãã¦å©ç¨ããããã®ã½ããã¦ã§ã¢ãMySQL Cluster 7.2ãã®æ£å¼çãå ¬éãã¾ããã GPLã«æºæ ãããªã¼ãã³ã½ã¼ã¹çã¨åæã«ã管çãã¼ã«ãå梱ãã24æé365æ¥ã®ãµãã¼ããè¡ãåç¨çã®ãMySQL Cluster Carrier Grade Editionããåæã«å ¬éãã¦ãã¾ãã ã¸ã§ã¤ã³ã70åé«éã« MySQL Cluster 7.2ã®æ大ã®ãã¤ã³ãã¯ãã¸ã§ã¤ã³ãé«éã«ãªã£ããã¨ã§ããããã¾ã§ã¯ã©ã¹ã¿ã§ã®ã¸ã§ã¤ã³ã¯ãã¸ã§ã¤ã³ãããã¼ãã«ã®ãã¼ã¿ãã¯ã©ã¹ã¿å ã®ãã¼ãéããã¡ãã¡é£ã³äº¤ã£ã¦ãããããè¤éãªã¸ã§ã¤ã³ã«ãªãã»ã©é ããã®ã«ãªã£ã¦ãã¾ããã MySQL Cluster 7.2ã§æ¡ç¨ãããAdaptive Query Localizationï¼ãããã¯Push Down Joinsï¼ã¨å¼ã°
大è¦æ¨¡ã²ã¼ã éå¶ã®ãã¤ã³ãï¼ãã¼ã¿ãã¼ã¹ã®ãã¥ã¼ãã³ã° ãã¼ã¿ãã¼ã¹ã®ãã¥ã¼ãã³ã°ã«ã¤ãã¦ãæ£å»¶æ°ã¯æ¬¡ã®7ã¤ã®ãã¤ã³ããæãã¾ããã 1ï¼net_slave_timeoutã¯çããã ã¹ã¬ã¼ããµã¼ãã§ã¯ããã°ãã°ã¬ããªã±ã¼ã·ã§ã³ãè¡ãããªããªã£ã¦ãããã¨ãããã¾ããããã¯ä½ããã®åå ã§ãã¹ã¿ã¼ã¨ã¹ã¬ã¼ãéã®ã³ãã¯ã·ã§ã³ã失ãããããã§ãããMySQLã¯ãã®ãã¨ãèªèãã¾ãããããããã¬ããªã±ã¼ã·ã§ã³éä¿¡ãè¡ãããªãå ´åã®ã³ãã¯ã·ã§ã³åæ¥ç¶æéããæ¨æºã§3,600ç§ã¨é常ã«é·ãå®è³ªçã§ã¯ããã¾ãããnet_slave_timeoutã®æéãçããããã¨ã§ãã¬ããªã±ã¼ã·ã§ã³ãæ¢ã¾ã£ã¦ãããã«åéã§ããããã«ãªãã¾ãã 2ï¼max_binlog_sizeã¯å°ãããã max_binlog_sizeã¯ãã¤ããªãã°ããã¼ãã¼ã·ã§ã³ããããµã¤ãºã®ãããå¤ãæå®ãã¾ãããæ¨æºã§1GBãè¨å®ããã¦ãã¾ãã
2. ä»åã®ç®ç 1. ããã¼ã¿ãä¿åãããã¨ãããã¨ããå®éã«ã© ããããã¨ãªã®ããç¥ãã 2. ä¸ã®åä½ãè¸ã¾ãããã¨ã§ãå¹çã®ããã¢ã ãªãæ¸ããããã«ãªãã 3. åé¡ãèµ·ããã¨ãã«ããã®åå ãçªãæ¢ãã ããããã«ãªãã ä¸è¬è«ãã¡ã¤ã³ã¨ããMySQLçã®ç´°ãã åå¥ãã¦ãã¦ã¯åãä¸ãã¾ããã 3. ãããªãã 1. ããã¼ã¿ãä¿åãããã¨ã¯ã©ããããã¨ã 2. MySQLããã£ã¹ã¯ã«æ¸ãã¾ã§ 3. ä»®æ³ã¡ã¢ãªã¨ãã¼ã¸ãã£ãã·ã¥ 4. ã¨ã£ã¦ãè¤éãªã¹ãã¬ã¼ã¸ã®åä½ 5. MySQLã®ã¤ã³ããã¯ã¹ã¨ã¡ã¢ãªã®é¢ä¿
2. èªå·±ç´¹ä» ï® MySQL/Linuxå¨ãã®ã¹ãã·ã£ãªã¹ã ï¬ 2006å¹´9æãã2010å¹´8æã¾ã§MySQLæ¬å®¶(MySQL/Sun/Oracle)㧠APAC/USåã®MySQLã³ã³ãµã«ãã£ã³ã°ã«å¾äº ï¬ ä¸»ãªèæ¸ã«ãç¾å ´ã§ä½¿ããMySQLããLinux-DBã·ã¹ãã æ§ç¯/ éç¨å ¥éããJavaãã¼ã¿ã¢ã¯ã»ã¹å®è·µè¬åº§ã ï® DeNAã§ã®ä¸»ãªå½¹å² ï¬ å®å®å/ããã©ã¼ãã³ã¹/éç¨å¨ãã®ä¸é·æçãªæ¹åæ´»å ï¬ L3ãµãã¼ã/éç¨/ãã©ãã«ã·ã¥ã¼ãã£ã³ã° â é£åº¦ã®é«ãMySQLå¨ãã®åé¡ã®æ ¹æ¬åå ã®ç¹å®ã¨è§£æ±º ï¬ å¤ãã®ããã¸ã§ã¯ãæ¯æ´ ï¬ ç¤¾å åå¼·ä¼/ãã¬ã¼ãã³ã° â MySQLããã¼ã¿ãã¼ã¹å¨ãã®ãã¹ããã©ã¯ãã£ã¹ã社å ã§å ±æãã æè¡ã¹ãã«ãåºä¸ããã ï¬ æè¡ãã¼ã±ãã£ã³ã° â å½å å¤ã®ã«ã³ãã¡ã¬ã³ã¹ããæè¡éèªç
ä»å¹´ãæ®ãã¨ãããã¨ãããã¨ãªã£ãã2010å¹´ãITæ¥çã«ã¨ã£ã¦ã¯å¤åã®å¤ãä¸å¹´ã ã£ãããçããã«ã¨ã£ã¦ã¯è¯ãå¹´ã ã£ãã ãããï¼æ¢ã«ä½åº¦ãMySQL 5.5ã®æ°æ©è½ã«ã¤ãã¦ã¯åãä¸ããããã¤ãã«æ£å¼çããªãªã¼ã¹ãããã¨ãããã¨ã§ããã§æ¹ãã¦æ°æ©è½ã解説ããä»å¹´æå¾ã®ã¨ã³ããªãç· ãããããã¨æãã MySQL 5.5ã«ã¯ããã§ããã£ï¼ã¨ãããããæ°æ©è½ã追å ããã¦ãããããããããããã¤ã¹ãªãã®ã°ããã ãä¸è¬çã«ã¯ãã½ããã¦ã§ã¢ã«æ°æ©è½ã追å ãããã¨éããªã£ããå®å®æ§ãä½ä¸ããäºä¾ãå¾ã絶ããªãã®ã ããMySQL 5.5ã«é¢ãã¦ã¯ãã®ãããªãã¨ã¯å ¨ããªãã®ã§å®å¿ãã¦å©ç¨ãã¦é ãããï¼ InnoDBã®å¤§å¹ ãªæ¹å種ã ããæ¹åç¹ã®ä¸ã§ãç¹ã«ç®ãã²ãã®ãInnoDBã¹ãã¬ã¼ã¸ã¨ã³ã¸ã³ã¸ã®æ¹è¯ã ãå®ã¯ãInnoDBã¯MySQL 5.1ãæåã«ãªãªã¼ã¹ãããã¨ãããã2åã¢ãããã¼ããè¡ããã¦ãããMy
MySQLã§ãã¼ãã«ã¸ã®ã«ã©ã 追å ãã¤ã³ããã¯ã¹è¿½å ããã¼ãã«ã®åç·¨æãªã©ãè¡ãã¨ããã®éãã¼ãã«ã«å ±æããã¯ãããã£ã¦ãã¾ãã¾ãããã®ãããããã®ã¡ã³ããã³ã¹å¦çã¯ãé常å©ç¨è ã®å°ãªãæ·±å¤æ©æ帯ã«ãµã¼ãã¹ãæ¢ãã¦å®æ½ããå¿ è¦ãããã¾ããæ¬æ¥ã¯ãããç¡åæ¢ããªã³ã©ã¤ã³ã®ã¾ã¾ã§ã§ããªããã¨ãã話é¡ã§ãã åºæ¬çãªã¢ã¤ã㢠ã¡ã³ããã³ã¹å¯¾è±¡ã®å ãã¼ãã«ãã³ãã¼ãã¦ãä½æ¥ç¨ã®ä»®ãã¼ãã«ãä½ãã¾ã ä»®ãã¼ãã«ã«å¯¾ãã¦ãã«ã©ã 追å ãªã©ã®å¤æ´ãå ãã¾ã ãã®éãå ãã¼ãã«ã«å¯¾ãã¦è¡ãããæ´æ°å¦çã«ã¤ãã¦å·®åãè¨é²ãã¦ããã¾ã ä»®ãã¼ãã«ã®å¤æ´ãçµãã£ãããè¨é²ãã¦ãããå·®åãã¼ã¿ãä»®ãã¼ãã«ã«åæ ãã¾ã å·®åãã¼ã¿ã®åæ ãçµãã£ãããå ãã¼ãã«ã¨ä»®ãã¼ãã«ãå ¥ãæ¿ãã¾ã ããã¨ä¼¼ããããªãã¨ãèããæ¹ã¯çµæ§ããã£ãããã®ã§ã¯ãªãã§ããããããã ãè¨ãã¯æããè¡ãã¯é£ãã§ããæ´åæ§ããã¡ãã¨åãããã©ã
Amazon RDSã¯ãã¯ã©ã¦ãä¸ã®MySQL 5.1ã§ãªã¬ã¼ã·ã§ãã«ãã¼ã¿ãã¼ã¹ãæ§ç¯ã§ãããµã¼ãã¹ãå¾æ¥ã®SimpleDBã¨ä½µç¨ã§ããã ç±³Amazon.comåä¸ã®Amazon Web Servicesã¯10æ27æ¥ãã¯ã©ã¦ãç°å¢ã§ãªã¬ã¼ã·ã§ãã«ãã¼ã¿ãã¼ã¹ãæ§ç¯ã»éå¶ã§ãããµã¼ãã¹ãAmazon Relational Database Serviceï¼RDSï¼ãã®Î²çãå ¬éããã Amazon RDSã¯ç±³Sun Microsystemsã®ãªã¼ãã³ã½ã¼ã¹ã®ãªã¬ã¼ã·ã§ãã«ãã¼ã¿ãã¼ã¹ãMySQL 5.1ãããã¼ã¹ã¨ãã¦ãããã¦ã¼ã¶ã¼ã¯RDS APIãã³ãã³ãã©ã¤ã³ãã¼ã«ã使ã£ã¦ã¯ã©ã¦ãä¸ã®RDSã«ã¢ã¯ã»ã¹ããæä½ã§ããã¨ããã Amazonã¯ãããã©ã¤ã¨ã¿ãªãªãã¼ã¿ãã¼ã¹ãµã¼ãã¹ãAmazon SimpleDBããæä¾ãã¦ããããSimpleDBã¯ã·ã³ãã«ãªã¤ã³ããã¯ã¹ã¨ã¯ã¨ãªãç¹å¾´ãª
å é±éææ¥ãBPStudy#25ã§ããããã©ã¼ãã³ã¹ã¨ã¹ã±ã¼ã©ããªãã£ã®ããã®ãã¼ã¿ãã¼ã¹ã¢ã¼ããã¯ãã£ãã¨ããé¡ç®ã§è©±ãããã¦ããã ãã¾ããããã®éã«ä½¿ç¨ããçºè¡¨è³æã¯ä»¥ä¸ã®ã¨ããã§ãã 1. Happy Optimization æåã«ãæé©åã®èãæ¹ã¨ãã¦ãä¸éå¤ãäºæ¸¬ãããããå ã«ãªã½ã¼ã¹é åãèãããã¨ããææ³ã説æãã¾ããã
Copyright (C) Mainichi Communications Inc. All rights reserved. æ²è¼è¨äºã®ç¡æ転è¼ãç¦ãã¾ã
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}