MySQL
ããã¾ããã®ã¾ãã¾ãªã®ã§ãããã¡ããã¨æ ããã¾ãã¦Laravel触ã£ã¦ããã§ããããã®åãããã©ã§VARBINARYæ±ãæ段ãªããã§ããããâ¦â¦ã DB::statement('ALTER TABLE (以ä¸ç¥ã¨ãã§ãå¯è½ããªã®ã¯ç解ãã¦ãããã§ãããããããã©ï½ãªã®ãï¼ãçãªãã§ã â¦
ã¡ã¨ãã¡ã®åãã MySQLã§ã¦ãã¼ã¯ãã¼ã¨PKãããã¼ãã«ã«å¯¾ãã¦ON DUPLICATE KEY UPDATEå¼µã£ã¦ãuniqueã§ã®éè¤ãããã¨auto incrementå¤é£ãããããã ãããã ã¨ããèå³æ·±ã話ãèããã®ã§ãæ©éå®é¨ã CREATE TABLE test ( id SERIAL, name VARCHAR(25â¦
MySQLã®ã(å°ãªãã¨ãä¸é¨ã§ã¯)æªåé«ã 0000-00-00 ã«ã¤ãã¦ãã¯ãããããããã°ãããã®ã§ããã ãããããPHP(plain)ã¨ã(PHPã®)ãã¬ã¼ã ã¯ã¼ã¯ã¨ãã§ã©ããã£ã¦ããã ãï¼ãã¨ããã®ãããã£ããã°ã°ã£ãéãã ã¨æ¡å¤ã¨ç¡ãã£ãã®ã§ã 調æ»ãã¦ãã¦ãâ¦
æè¿å°ããä½ãæ¹ãå¤ãã£ãã®ãå¤ããã®ãã ãããªããæ¹ããã¦ããã¨ãå¤ãã§ããã£ã¦ã®ããã£ãã®ã§åå¿é²ã create database ãã¼ã¿ãã¼ã¹å; CREATE USER 'ã¦ã¼ã¶å'@'ãµã¼ãå' IDENTIFIED BY 'ãã¹ã¯ã¼ã'; GRANT ALL ON ãã¼ã¿ãã¼ã¹å.* TO 'univcâ¦
ãµã¨çå¾ããã«è³ªåãããã ããã®ããã£ã¦ã ã¡ããã©ãããã£ããã«ãªã£ãã®ã§ããã£ãããªãã§Blogã§ã æ¬è³ªçã«ã¯ãã©ã®è¨èªã®ã©ã®é åãã§ãããç¨åº¦å¿ç¨ãå©ããã¨æããã¾ããã ä¸å¿ãããã¡ããã®è¨è¿°ãªãã§ãMySQLã§PHPã¤ãã£ãWebã¢ããªã±ã¼ã·ã§â¦
ã¨ããããããã£ããã¨æ¥ç¶ãã¦ãã¼ã¿ãfetchAllã§ã²ãã£ã¦ããã²ãããäºããã»ãã®ãã¨ç¢ºèªãã¦ã¿ã¾ãããã åºæ¬ã«ãªãã³ã¼ãã¯ä»¥ä¸ã®éãã 移è¡ãSQL以éé¨åã ãé©å®ãããããªãããã£ã¦ããã¾ãã false, ); // ãè¤æç¦æ¢ããå¯è½ãªãä»ã足ãã¦â¦
ã¨ãããããæèã®æµãã¨èª¿æ»ã®æµããããã®ã¾ã¾æ¸ãã®ã§ãèªã¿ã«ããã®ã¯ããããªããã¾ãã ã¾ãã¯ããã¤ãæ¤è¨¼ãã¼ãã«ãç¨æâ¦ããåã«ãMySQLèªä½ã®åãã®ç¢ºèªãã ç´è¿ãåèã«ããã¦ããã ããã®ã¯ãhnwããã®ãã¡ãã®ãµã¤ãã http://d.hatena.ne.jpâ¦
ããã¿ã¤ãã³ã°ã§ãããªãã¢ãã¹ãã¼ãã¡ã³ãåãã®ã話ã¨ãIDã®ã«ã©ã (ã«ãã£ã¦æ±ºã¾ãæ大å¤)ã®ã話ã¨ãintãµã¤ãºã®ã話ãå¥ã ã«æ¥ãæã«â¦â¦é ãä¸ã§æ··ãã£ã¦ããããï¼ãã¨æã£ãäºããã£ãã®ã§èª¿ã¹ã¦ã¿ããã£ã¦æãã«ãªãã¾ãã ã¾ã話ã«åºã¦ããã®ããAUTâ¦
大æ¬ãã¿ã¯ãã¡ãã http://moriyoshi.hatenablog.com/entry/2017/03/13/011005 ããã§ãç°ä½åã»ã¬ã¯ã¿ãã£ã¦ã®ãã¯ããã¦ç¥ã£ã¦ãã¡ããã£ã¨èª¿ã¹ãã®ãããã®ã§ãåå¿é²çã«ã Unicodeã£ã¤ãUTF-8ã§ãï¼æåã¥ã¤ãã«åå²ãããã«ããã«ããæ¸ããããããªâ¦
ãã¡ãã¨ææ¡ããã人以å¤ã¯ç¹ã«èªã¾ãªãã¦ãã¤ã¤å å®¹ï½ ãã ã¾ãããã¡ãã¨ããææ¡ãããã«ä½¿ã人ããæè¡è ãªã®ãï¼ ã¨ããåãããããã¡ããçã«ã¯ãã£ãããããã ãã©ãã¾ã人ãããããªã®ã§ã containersãã¼ãã«ã«ã¤ãã¦å°ã åºæ¬çã¯ãåè¿°ã®éãâ¦
ããã¾ãã¡ããã¨èª¿æ»ãã¦ãªããã§ãæ¬æ°ã§åå¿é²ç¨åº¦ã ã¨ãããããmemslapã§ç°¡åã«ãã³ããã¼ã¯ç¢ºèªãã¦ããã¾ããã # 10,000åã®ãã¹ã memslap --servers=localhost --test set memslap --servers=localhost --test get 以ä¸ã®ãã©ã¡ã¿ããã¥ã¼ãã³ã°â¦
ã¨ããããã以ä¸ãå ã«ãã£ã¦ããã¾ããããã»å¿ è¦ãªconfigã®è¨å®(SQLæãæµãã) cat ./plugin/innodb_memcached/innodb_memcache/scripts/innodb_memcached_config.sql | mysql -u root ã»ãã©ã°ã¤ã³ã®è¨å®(SQL ã³ã³ã½ã¼ã«ã«ã¦) install plugin daemon_meâ¦
ã»ã¼å®å ¨ã«åå¿é²ãªä¸ã«ããã£ãæé ã«æ²¿ã£ã¦ãã®å 容ãªãã§ãæ¿ããé·ãã§ã(è¦ç¬ å ã«çµè«ã ãæ¸ãã¦ãã㨠ã»æ ¼ç´å ãã¼ãã«ã¯ä»»æã«é¸ã¹ã ã»keyã«ã¤ãã¦ã¯â¦ ï¼charã¨varcharããããç¸æ§ããããã ãã©ãintãããã ï¼varbinaryãç¸æ§æªãã¦ãæ ã«ã'Aâ¦
MySQLã«ãã¼ã¿ãå ¥ãããã¨ããã Incorrect datetime value ã§æãããã â¦ãªãã§ã ãï¼ ã£ã¦æã£ãããtimestampåã§ã'2054-1-1 22:33:44'ã£ã¦å¤ãå ¥ãããã¨ãã¦ãã timestampã£ã¦ãTIMESTAMP ãã¼ã¿åã®ç¯å²ã¯ã'1970-01-01 00:00:01' UTC ãã '2038-â¦
ã¡ã¨ç¢ºèªããããã¨ããã£ãã®ã§ã ãã£ãã¡ã¢æ¸ããªã®ã§ãé©å®è³å ä¿ç®¡ãã¤ã¤èªãã§ãã ããã¾ãã ã¨ãããã set global long_query_time = 0; set global slow_query_log = 'on';ãã¦ãMySQLå´ã«æ¸¡ã£ã¦ãããã®ãè¦ãã¦ã¿ããããªãã¨ãç»çã create taâ¦
ããããã°ãcmake使ãããã«ãªã£ã¦ãããããªããã«é¢åã ã£ãã®ã§ãã¡ã¢ã installããã®ã¯â¦ï¼æã®é ããã ã£ãã®ã§ããã¼ã¸ã§ã³ã¯é©å®èªã¿æ¿ãã¦ã¡ãã wget http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz tar zvxf cmake-2.8.7.tar.gz cd cmake-2â¦
MySQLã®ã¬ããªã±ã¼ã·ã§ã³å¨ãã ä»åº¦ã¾ã¨ããã¨ãã¦ãåèã«ãªã£ãæ°ã ã®URIãåæã http://wiki.bit-hive.com/tomizoo/pg/MySQL%20%A5%EC%A5%D7%A5%EA%A5%B1%A1%BC%A5%B7%A5%E7%A5%F3%A4%CE%C0%DF%C4%EA http://www.irori.org/doc/mysql-rep.html http://nâ¦
ãªããè²ã ã¨è³ææ£ããã£ã¦ããå¿ãã¦ããã§ãæ£ã ã¨é¢åã ã£ãã®ã§ã å¾ã§ä»ã足ãåæã§ãæå ã«ãããæ£ããã£ãè³æããæ´çãã¦ã¾ã¨ãã¦ããã¾ãçãªmemoã â¦ããå ã«ãset globalã¨ãã¯ããããæ¿ãããã¼ããã·ã§ã³ããè¦æ±ãããã®ã§ã注æã®ã»ã©ãâ¦
ã¨ããããã¢ãã¦ãã«memoã ãããããã¨ã drop table session_test; create table session_test ( session_id varbinary(256) not null, use_id varbinary(64) not null, data blob, insert_date datetime, update_date datetime, PRIMARY KEY (session_iâ¦
ã§ã£ãããã¼ãã«ãã¾ãã£ã¨æ´æ°ããæ¹æ³ã®ã²ã¨ã¤ ã®å¿ç¨ç·¨ã¨å°ã£ããã¨
ãã§ã ããã®äºç¨®ã¨ãã¦ãé¨åçã«å ¥ãæ¿ãããäºãããããã¨ãããã¾ãã ãã¨â¦ä½æã ã¨ãæ±äº¬é½ã ãå ¥ãæ¿ãããã¨ãã trancate éµä¾¿çªå·ãã¼ãã«_tmp; loop insert into éµä¾¿çªå·ãã¼ãã«_tmp(...) values(...); begin; delete from éµä¾¿çªå·ãã¼ãã« â¦
ãã¨â¦ä¾ãã°ãéµä¾¿çªå·ãkeyã«ããä½æãã¼ãã«ããªãã¦ã®ããå²ã¨ããããããã¨ããã§ããã®ã§ããã ãã®åãæ´æ°ããå ´åãæ®éã«èãã㨠begin; trancate éµä¾¿çªå·ãã¼ãã«; loop insert into éµä¾¿çªå·ãã¼ãã«(...) values(...); commit; ã£ã¦ãªå¦çâ¦
REPLACEã¯ããªããinsertããã£ããdeleteï¼insertããªã®ã§ãå¹³ãããä¸æ¸ãããSNSã®è¶³è·¡ãªããã«ãã£ã便å©ã ON DUPLICATE KEYã¯ããªããinsertããã£ããupdateããªã®ã§ãã«ã¦ã³ã¿ç³»ã¨ãã®å®è£ ã«ãã£ã便å©ã â¦æããããããã«ç¶ºéºã«è¨æ¶ããæãã¦ããâ¦
ã¨ããããã¢ãã¦ãã«memoã ãã¨ã§æ´çâ¦äºå®(è¦ç¬ 確èªé¢é£ show variables like 'character_set%'; show variables like "char%"; status show create database ãã¼ã¿ãã¼ã¹å \G show create table ãã¼ãã«å \G è¨å®é¢é£ [client] default-character-sâ¦
create database ã§ããã¹ããå; grant ALTER, CREATE, DELETE, DROP, INDEX, INSERT, LOCK TABLES, SELECT, UPDATE on ã§ããã¹ããå.* to ã¦ã¼ã¶å@ãã¹ãå identified by 'ã±ãããã©'; flush privileges ;ã¡ãªã¿ã«ãã±ãããã©ä½æãã«ã¯ãã¡ãã便å©â¦
int mysql_insert_id ([ resource $link_identifier ] ) ã¾ã㯠SELECT LAST_INSERT_ID(); ã®ããããã§åå¾ã DBãã³ãã«æ¯ã«ã¦ãã¼ã¯ã«å¤ããã£ã¦ãããããã®ã§ç¡åé¡â¦ã®ãã¯ããæªæ¤è¨¼ã ãã©ã
æ大æ¥ç¶æ°ãç¥ãããæ echo "show variables" | mysql | grep max_connectionsã§ãè¨å®æ°ãå¢ããããæã®my.cnfã¸ã®è¨è¿° [mysqld] set-variable = max_connections=500ã§ãmax_connectionsã¨ï¼ã¨500ã®éã¯ã¹ãã¼ã¹å ¥ããã¨ã¨ã©ãã®ã§æ³¨æã
ãã¨ãã¡ã¨è²ã ããã¾ã㦠ç¾è¡æ¬çªã®DBãè²ã ãããã£ã¦ãã¨ãããããã¡ã¨ç´°å·¥ãªã©ãã¤ã¤ãå¸ãä¸ããã æ¬çªDBãããã¶ã£ã¡ãããuptimeã¨ããããäºã«ãªã£ã¦ã orzã 幸ããããã¤ãå¥ãã·ã³ããã ã£ã¦ç¶æ³ããè³ç«ã¦ã¨ãã¦ããã¾ãã¦ã ã¾ã ä¸ç¬ã ãMâ¦
ãã¨ã ã¡ã¨ã¨ããæ¥åã§è²ã ããã¾ãã¦ãintã§æå®ããã«ã©ã ã«å°æ°ç¹ãªæ°å¤ãã¯ãããäºæ ãçºçãã¾ãã¦ã ããã¾ãäºæ¬¡ãã¼ã¿ãªãã§çµæ§æ°ãæãã¦ããã§ãã orz ããã¨ãã¦ã ãã¨â¦ã¡ãã£ã¨èå³æ·±ããã¼ã¿ãè¦ã¤ããã¾ãã¦å®é¨ããã¦ã¿ãããã¾ããã â¦
via http://www.res-system.com/weblog/item/582ãã¨ããã¼ã¯ã¼ãã¨ãã¦ã¯ãMySQLã§æã å¦ã«éããªããã¨ããããã»ã¹æ°ãmaxãã£ã¡ãã£ã¦connectåºæ¥ãªããã¨ããããªäºè±¡ã mysqlã³ã³ã½ã¼ã«ã§ãã°ã¤ã³ãã¦show processlistã³ãã³ãã¨ãã§è¦ãã¨ãunauthentâ¦
http://itpro.nikkeibp.co.jp/article/NEWS/20080117/291269/ SunãMySQLã10åãã«ã§è²·åï¼ãã¤ã«ã«ã®é£ç¿ãæå©ããç±³Sun Microsystemsã¯1æ16æ¥ï¼ç±³å½æéï¼ï¼ãªã¼ãã³ã½ã¼ã¹ã»ãã¼ã¿ãã¼ã¹ã®å¤§æã§ããã¹ã¦ã§ã¼ãã³MySQLã10åãã«ã§è²·åããã¨çºè¡¨ããâ¦