MySQL
â Aurora ã® ã¹ãã¬ã¼ã¸ ãï¼ã ã¯ã©ã¹ã¿ã¼ããªã¥ã¼ã ãï¼ã ãã¼ã«ã«ã¹ãã¬ã¼ã¸ ãï¼ã ã¯ã©ã¹ã¿ã¼ããªã¥ã¼ã * 3ã¤ã®ã¢ãã¤ã©ããªãã£ã¾ã¼ã³ã«ã¾ãããSSDï¼Solid State Diskï¼ãå©ç¨ããã¹ãã¬ã¼ã¸ãDBã¯ã©ã¹ã¿ã¼åä½ã§ä¿æ => ãã¼ã¿ã¯ã¢ãã¤ã©ããªãã£â¦
â ã¯ããã« * 2018/04/19ã«ãMySQL 8.0.11 (GAç)ããæ£å¼ãªãªã¼ã¹ãããã®ã§ã試ãã¦ã¿ã * ãªããv5.7 ã®ã¤ã³ã¹ãã¼ã«ã«ã¤ãã¦ã¯ã以ä¸ã®é¢é£è¨äºãåç §ã®ãã¨ã https://blogs.yahoo.co.jp/dk521123/36283180.html è£è¶³ï¼GAã«ã¤ã㦠* GA : General Availâ¦
ãï¼ãMySQLã®JDBCãã©ã¤ããä¸ãããã¨ã©ã¼ãThe server time zone valueãã«ãªã ç¾è±¡è©³ç´° MySQLã®JDBCãã©ã¤ãã v5.1.46 ãã v8.0.11 ã«ãããã¨ãã¨ã 以ä¸ã®ãã¨ã©ã¼å 容ãã«ãªã build.gradle ä¿®æ£å (ç¾è±¡çºçãªã) dependencies { // MySQL compilâ¦
â ã¯ããã« * ãã¼ãã«ã®BOOL(BIT)é ç®ã«å¯¾ãã¦ãGROUP BYããå¾ã«è«çæ¼ç® OR ããããã£ãã®ã§èª¿ã¹ã¦ã¿ã ãMySQLãè§£æ±ºæ¡ * BIT_OR() ã£ã¦ã®ããã å ¬å¼ãµã¤ã https://dev.mysql.com/doc/refman/5.6/ja/group-by-functions.html â å®è¡ç°å¢ * DB : MySQLâ¦
ãï¼ãLIMIT * åºåããè¡æ°ãå¶éãã * PostgreSQL ã Snowflake ã§ã使ããã¿ãã ãï¼ãæ§æ SELECT [é ç®1] (, ...) FROM [ãã¼ãã«å] LIMIT ([éå§ä½ç½®ï¼è¡æ°],) åå¾ããè¡æ° ãï¼ããµã³ãã« SELECT * FROM user LIMIT 5 ï¼ï¼åºåçµæ "1" "1" "Kim"â¦
â ã¯ããã« https://dk521123.hatenablog.com/entry/2010/04/01/175501 ã§ãã£ãã¤ã³ããã¯ã¹ãè¡ã£ãããMySQLã«çµã£ã¦æ¸ãã ç®æ¬¡ ãï¼ãã¤ã³ããã¯ã¹ç¨®é¡ ãï¼ãã¤ã³ããã¯ã¹ä½æ ãï¼ãã¤ã³ããã¯ã¹åé¤ ãï¼ãã¤ã³ããã¯ã¹æ å ±è¡¨ç¤º ãï¼ãã¤ã³ããã¯ã¹â¦
ãï¼ãã¹ãã¢ãããã·ã¼ã¸ã£ * CREATE PROCEDURE ã使ã ï¼ï¼å®ç¾© delimiter // CREATE PROCEDURE `give_hello` (OUT result VARCHAR(30)) COMMENT 'Hello World! for stored procedure.' LANGUAGE SQL BEGIN SELECT COUNT(*) FROM customer INTO result; ENâ¦
â ã¯ã©ã¤ã¢ã³ãã®åææ¥ç¶æå¤§æ° max_connections ç®ç * MySQLã¯ã©ã¤ã¢ã³ãããç¡å¶éã«ã³ãã¯ã·ã§ã³ãå¼µããããã¨ã«ãã£ã¦MySQLãµã¼ãã®è² è·ãå¢å¤§ãã æçµçã«ã¯ãµã¼ãã¹ãåæ¢ãã¦ãã¾ããã¨ãé²ãããã«ãæ¬ãã©ã¡ã¼ã¿ã§ã¢ã¯ã»ã¹å¶éãã¦ãã è£è¶³ * â¦
â ããªã¬ã¼ * ãã¼ãã«æä½ï¼UPDATE/INSERT/DELETE)ãè¡ãããæã« ã¤ãã³ãé§åã§å®è¡ããä»çµã¿ â ããªã¬ã¼ã®ä½æ æ§æ DELIMITER // CREATE TRIGGER ãããªã¬ã¼åã ãBEFORE or AFTERã ãINSERT or UPDATE or DELETEã ON ã対象ãã¼ãã«åã FOR EACH â¦
â ã¯ããã« ãmysqldump --all-databasesãã®å ´åã MySQLèªä½ã®ã·ã¹ãã ã«é¢ããDBãinformation_schemaããperformance_schemaããmysqlããsysããå«ãã 形㧠ã¨ã¯ã¹ãã¼ããã¦ãã¾ãã®ã§ããã®ãã¨ãèæ ®ããã·ã§ã«ã¹ã¯ãªãããæ¸ãã¦ã¿ã mysqldump ã«â¦
â CONCAT * æååãçµåãã ãµã³ãã« ä¾1 select CONCAT('Hello', ' ', 'World', '!!') åºåçµæä¾ Hello World!! ä¾2 select CONCAT(c.first_name, ' ', c.family_name) from customer c åºåçµæä¾ Mike Abel Ken Allen Kevin Cox Smith Abel Ken Dean Tâ¦
â å®è¡æéãæããSQLã®ç£è¦ææ³ [1] show full processlist ã§ãå®è¡ä¸ã®SQLã表示ãã [2] slow_query_log / long_query_time ã使ã£ã¦ãé ãã¯ã¨ãªãç¹å®ãã [1] show full processlist ã§ãå®è¡ä¸ã®SQLã表示ãã G ãªãã·ã§ã³ã§ã¯ã¨ãªçµæãåç´è¡¨ç¤ºâ¦
â MySQL Utilities ã¨ã¯ï¼ * Pythonè¨èªã«ããä½æããã便å©ãªã³ãã³ãã©ã¤ã³ãã¼ã«ç¾¤ mysqlserverclone * åä½ä¸ã®MySQLãå ã«å¥ã¤ã³ã¹ã¿ã³ã¹ãéå§ * 注æç¹ * ã¯ãã¼ã³å ãããã¼ã¿ãã¼ã¹ãªãã¸ã§ã¯ãï¼è¡¨ããã¥ã¼ãããã·ã¸ã£ããã©ã³ã¶ã¯ã·ã§ã³ãçï¼â¦
â ã¯ããã« https://qiita.com/tonishy/items/542f7dd10cc43fd299ab ã¨ãåãã§ãAurora 1.14 å¼·å¶ã¢ããã°ã¬ã¼ãéç¥ãæ¥ãã http://docs.aws.amazon.com/ja_jp/AmazonRDS/latest/UserGuide/Aurora.DatabaseEngineUpdates.html ã«ããã¨ããæ´æ°ã§ã¯ããã¼â¦
â ã¯ããã« ãã¼ãã«ã«ã¯ãããä½ææ¥æãæ´æ°æ¥æãä»ãããã¨ãå¤ãã ãããã«ä»ä¸ãããèªååæåãããã³ãæ´æ°æ©è½ããããã®ã§åãä¸ãã ã¾ãã使ç¨ããéã®æ³¨æç¹ãè¨ãã â æ§æï¼CREATE TABLEï¼ ã»ã»ã»ç¥ã»ã»ã» ãä½ææ¥æã DATETIME NOT NULL â¦
â ã¯ããã« https://blogs.yahoo.co.jp/dk521123/36225584.html ã§æ±ã£ãInsert or UpdateãINSERT INTO ï½ ON DUPLICATE KEY UPDATE ï½ã㧠ç²ç¹ã ã£ããã¨ãã¾ã¨ããã â 使ç¨ä¸ã®æ³¨æ * AUTO_INCREMENT ã使ç¨ãã¦ãããã¼ãã«ã§ããINSERT INTO ï½ ON DUâ¦
â ã¯ããã« éçºç°å¢ã¯ãMySQL v5.7 ã ããæ¬çªç°å¢ã® AWS / Aurora ã使ã£ã¦ããå ´åã 2017/08/19ç¾å¨ãAurora ã¯ãMySQL v5.6 ã¨å¼·ãäºææ§ãããã®ã§ã éçºç°å¢ãv5.6ã«åããã¦ããããã£ã¦ã±ã¼ã¹ã£ã¦ããå¾ãã®ãã¨ã ãããã訳ã§ãMySQL v5.7 ãã â¦
ãªã¼ããªã³ãªã¼ ã®ã¦ã¼ã¶ãä½æãã 主ãªæ¹æ³ã¯ä»¥ä¸ã [1] ã³ãã³ãã§ä½æ [2] GUIãã¼ã«ã§ä½æ [1] ã³ãã³ãã§ä½æ mysql -u root # ãã¹ã¯ã¼ãå ¥å # ã¦ã¼ã¶ä½æ mysql> CREATE USER readonlyuser IDENTIFIED BY 'Passwd2#'; # GRANT SELECT ON *.* TO <ã¦â¦
â ã¯ããã« https://blogs.yahoo.co.jp/dk521123/36680883.html ã§ãã¨ã¯ã¹ãã¼ããããã³ããã¡ã¤ã«ã大éã«å®è¡ãããã·ã§ã«ãæ¸ã â ä»æ§æ¦è¦ 以ä¸ã®ãããªã«ã¼ã«ã§å®è£ ãã¦ã¿ã * åä¸é層ã«ç½®ããããã³ããã¡ã¤ã«ï¼æ¡å¼µåã*.sqlãï¼ãå®è¡ãã * ãã³â¦
â ã¯ããã« * 以ä¸ã®ãåé¡ã®ç¾è±¡ãã®è§£æ±ºçã¨ãã¦ä½¿ç¨ããããã¼ãã¼ãã«ãDUALãã«ã¤ãã¦ãåãä¸ãã â åé¡ã®ç¾è±¡ * MySQL ã§åé¡ãªãã£ãSQLæãINSERT SELECTæãããAmazon Aurola ã§SQLææ³ã¨ã©ã¼ã«ãªã£ã çºçç°å¢ åé¡ããã£ãAuroraã®ãã¼ã¸ã§ã³ â¦
â ã¯ããã« http://blogs.yahoo.co.jp/dk521123/36589352.html ã§è§¦ãã mysqldump ã«ã¤ãã¦ãæ±ãã â 使ãã©ãã ã¤ã³ãã¼ã/ã¨ã¯ã¹ãã¼ã [1] ãã¼ã¿ç§»è¡ [2] ããã¯ã¢ãã etc... â ã¨ã¯ã¹ãã¼ã * mysqldumpã使ç¨ãã æ§æ å ¨ã¦ã®DBãã¨ã¯ã¹ãã¼ãããâ¦
â ç¾ç¶ã®è¨å®ã確èªãã SHOW VARIABLES LIKE '%time_zone%'; â ã¿ã¤ã ã¾ã¼ã³ã®å¤æ´ã«ã¤ã㦠time_zone in Linux http://qiita.com/tailak/items/63dce2dd7dfe049b038e ãåèã«ãªã [1] 以ä¸ã®ã³ãã³ããå®è¡ããã¿ã¤ã ã¾ã¼ã³ãã¼ã¿ã§ã¤ã³ãã¼ããã ï½ï½ï½â¦
â ã¯ããã« http://blogs.yahoo.co.jp/dk521123/36493945.html ã®Windowsçã â æé [1] MySQLã®ã¤ã³ã¹ãã¼ã«å ´æï¼ããã©ã«ããªããC:\ProgramData\MySQL\MySQL Server X.Xãï¼ ã«ãããmy.iniããã³ãã¼&ãã¼ã¹ãããä»»æã®ãã¡ã¤ã«åï¼ä¾ãmy2.iniãï¼ã«â¦
â æ¹æ³ [1] mysqldump ã使ã£ã¦ããã¯ã¢ãã [2] Workbenchã使ã£ã¦ãã¼ã¿ç§»è¡ [3] SELECT-INERTã§ãã¼ã¿ç§»è¡ [1] mysqldump ã使ã£ã¦ããã¯ã¢ãã * 以ä¸ã®é¢é£è¨äºãåç §ã®ã㨠http://blogs.yahoo.co.jp/dk521123/36680883.html [2] Workbenchã使ã£ã¦ãâ¦
MySQL 㧠SSLæ¥ç¶ ãããã è¨å®ãæå¹ã«ãªã£ã¦ãããç¢ºèª SHOW VARIABLES LIKE '%ssl%'; SSLæ¥ç¶ãå¼·å¶ãã ãREQUIRE SSLããä»ä¸ GRANT ALL PRIVILEGES ON *.* TO user_name@'%' IDENTIFIED BY 'password' REQUIRE SSL; ãã©ãã« è¦åï¼Establishing SSL â¦
ã¯ããã« http://blogs.yahoo.co.jp/dk521123/36225584.html ã§INSERT or UPDATEãæ±ã£ãããæ¡ä»¶ä»ãã§UPDATEã§ããäºãèãã 解決æ¹æ³ * DUPLICATE KEY UPDATEå ã§ãIFæãã¾ã㯠CASEæã使ã IFæ IFï¼ãæ¡ä»¶å¼ã, ãçã®å ´åã®å¤ã, ãå½ã®å ´åã®å¤ã)â¦
â æ¹æ³ [1] mysqld_multi ãå©ç¨ãã => MySQL 5.6以åã®æ¹æ³ã [2] systemctlãå©ç¨ããæ¹æ³ => MySQL 5.7.13以éã®æ¹æ³ãä»åã¯ããã£ã¡ãæ±ãã â»ãã¼ã¸ã§ã³ã確èªããã«ã¯ãmysql --versionããå®è¡ãã â ç°å¢ * OS : CentOS7 * DB : MySQL5.7.16 â åâ¦
â MySQL ã§ããã¼ã¿ãæå·å / 復å·å ãã æ¹æ³ * AES_ENCRYPT() / AES_DECRYPT() ãªã©ã®æå·åé¢æ°ã使ç¨ãã https://dev.mysql.com/doc/refman/5.6/ja/encryption-functions.html â ä¾ï¼ ãã¼ãã« CREATE TABLE IF NOT EXISTS `user` ( `user_id` VARCHAâ¦
æ¥ä» / æ¥æã®å·®å DATEDIFF * æ¥ä»ã®å·®å SELECT DATEDIFF('2016-08-06 12:00:22','2016-08-07 11:00:22'); # -1 TIMEDIFF * æéã®å·®å SELECT TIMEDIFF('2016-08-06 12:00:22','2016-08-07 11:00:22'); # -23:00:00 ⻠使ç¨ããå ´åã¯ã以ä¸ã®ãâ TIMEDIFFâ¦
ãï¼ããé¡ * ç¾å¨æ¥æã«è¿ãé ã«ã½ã¼ãããéè¤ãæé¤ãã ãï¼ããµã³ãã« * 顧客ãã¼ãã«ãcustomerãã¨äºç´ãã¼ãã«ãreservationããããã äºç´æ¥æã«å¯¾ãã¦ãç¾å¨æ¥æã«è¿ãé ã«ã½ã¼ããã 顧客åã®éè¤ãæé¤ãããã¼ã¿ãåå¾ãã ï¼ï¼ãã¼ãã« custoâ¦