ϡɥǥƥʥ ֥

ϡɥǥοǡʪեޥåȡŲLinuxСMySQLʤɤᥤäΤǤθ幭ꡢϡɥƤƤޤ ХǥХϡMacBookAir(13)iPad Air2ݥ DM100(󥰥)OLYMPUS STYLUS XZ-2ʤɡ Ȥʤ顢֥򹹿Ƥޤ

MySQL






2߰ʲη¥СҲ𤷤褦

ٻ PRIMERGY MX130 S2

PRIMERGY MX130 S2

19,800ߤ2,000߰ݥѤ17,800ߡ

߸˶Ͼ

OS쥹פʬLinux뤫פ͡

CPU꡼ϡɥǥ(250GB)DVD-ROMɥ饤֤ܤäƤ뤫顢ȤLinuxƤƥ󥹥ȡ뤹

¥СϥȾɤƤˤʤ롣

桢෿֤ǽʥСϥ͡

ܤNASΥС⤢衣

HP ProLiant MicroServer Turion II NEO N5

HP ProLiant MicroServer Turion II NEO N5

16,980ߤ1,000߰ݥѤ15,980ߡ

߸˶Ͼ

CPU꡼ϡɥǥ(500GB)Ϥ뤬إɥ饤֤ʤΤѰդ뤫USB꡼饤󥹥ȡ뤹Ф褤

Linuxƥե륵СˤƤ襷MySQLDBγؽѤˤƤ襷

Сδϡϡɤޤ᤿μɬǤȡϹͤƤ롣

ʤСϤµ

CD SQL Ϥǡ١ (ץߥ󥰳ؽ꡼)
CD SQL Ϥǡ١ (ץߥ󥰳ؽ꡼)
posted with amazlet at 14.09.07
ߥå
Ʊ˼
夲󥭥: 4,658


MySQLǽХ֥ ~ΩAtoZ~
MySQLǽХ֥ ~ΩAtoZ~
posted with amazlet at 14.09.07

ɾ
夲󥭥: 61,578


ϥѥեޥMySQL 3
ϥѥեޥMySQL 3
posted with amazlet at 14.09.07
Baron Schwartz Peter Zaitsev Vadim Tkachenko
饤꡼ѥ
夲󥭥: 112,943

[PR] au WALLETɤξ - auΥץڥɥɤǥåԥ󥰤򤪥ȥˡ

Υȥ꡼ϤƤʥ֥åޡɲ mixiå Share on Tumblr Clip to Evernote






ǡ١ǽפindexǤ뤬ƤfieldindexΤϡ¿ξ̵̤Ǥ롣

Ƥ⡢줬Ѥʤа̣ʤ

index뤳ȤϡfieldΥԡ뤳Ȥ˶᤯ǽ㲼򾷤

ƤfieldindexɲäСơ֥뤬2ĤΤƱ

ȯȡξ˽񤭹ޤͤФʤʤ(Ʊ)

indexΩĤʬʤΤˡƤfieldФindexꤹΤ̵̡

ɼ褬ᥤξϡʤϥޥ...

indexꤷƤȤʤfieldϡۤɹͤʤƤʬϤ

褯Τ祭ˤϴindexΤˡȤ̤indexƤѥ

Ĺ̵̤Ǥ롣

ʤSQLˤäƤϡindexΩʤ(Ȥʤ)⤢롣

̾ϡĢõ롣

Ģˤϡν¤Ǥ뤫

̾ξϡ줬Ȥʤ

ƤФơ̾Ǥǽ뤫

ʣindex(sei),̾(mei)νꤷƤ⡢̾ǤSELECTˤΩʤ

Ʊͤˡ̾ˤORDER BYˤΩʤ

SELECT * FROM `user` ORDER BY `mei`,`sei` ;

ޤLIKE'%'%줿()⡢Ƥ˰פǽΤindexΩʤ

'%%'ȶְפƱ͡

黻ƤӤʤɤ⡢indexΩʤ

WHERE `price` * 1.08 > 1000 ;

Τ褦ʾ硣

indexˤǡ`price`Ǥä`price` * 1.08ǤϤʤ

ϡξդ1.08dzä

WHERE `price` > 1000/1.08 ;

ȤȡindexѤǤ褦ˤʤ롣

()䡢IS NULLOR⡢indexѤǤʤ

âORINǽ񤭴ȡindexѤǤ褦ˤʤ롣

EXPLAINǡꤷindexpossible_keys˴ޤޤƤꡢkeyǼºݤѤƤ뤫ǧƤ

ãͤ˳ؤDB߷ Ű Ԥǽꤿʤʤ
ãͤ˳ؤDB߷ Ű Ԥǽꤿʤʤ
posted with amazlet at 14.06.29
ߥå
Ʊ˼
夲󥭥: 10,850


ʲSQLѥϤᡣ

Ʋ⤷Ƥ롣

줳졢뤢롪ߤʣ

ʤưƤ뤫顢ȤSQLν򤷤Ƥȡ쥳ɤȽŤʤäꤷʤ

ȤΤȤͤƤʤΤ͡

ޤͽ̤ۤSELECTƤ뤫OKȽǤꤷƤʤ

͡ʥ쥳ɤƤ硢ͽʤ̤֤Ƥʤ

SQLѥ
SQLѥ
posted with amazlet at 14.06.29
Bill Karwin
饤꡼ѥ
夲󥭥: 7,908


SQLǷѴְռˡפƤޤ졩indexѤƤʤȤ
[PR] au WALLETɤξ - auΥץڥɥɤǥåԥ󥰤򤪥ȥˡ

Υȥ꡼ϤƤʥ֥åޡɲ mixiå Share on Tumblr Clip to Evernote






饤󥿡ͥåΥ󥿥륵С°ǡ١˿ǡ١ɲä(CREATE DATABASE)ˤϡȥѥͥ뤫餷Ǥʤ(phpMyAdminϤǤʤ)

ֿΤäƤʤȡǡ١Υԡˤ⼺Ԥ뤳Ȥˤʤ롣

ǡ١Υԡϡޤǡ١ξǥǡ򥳥ԡ롣

Ĥޤꡢǡ١κɬפȤʤ롣

phpMyAdminǡ١Υԡ¹Ԥ褦Ȥȡκݤ CREATE DATABASE ¹Ԥ褦ȤƼԤΤ

# 1044 - Access denied for user 'xxx' to database 'xxx'

# 1044 - Access denied for user 'yyy' to database 'xxx'

(桼yyyΥǡ١xxxؤΥݤޤ)

äơǡ١򥳥ԡˤϡޤȥѥͥ뤫ǡ١롣

ǡ١

ξǡDB

֥ԡ CREATE DATABASE

Υåǡ١˸Ƽ¹ԤСԡǤ롣

ǡ١Υԡ

åդޤޤȡCREATE DATABASE Ǥʤᡢ

# 1007 - Can't create database 'xxx' ; database exists

# 1007 - Can't create database 'xxx' ; database exists

(ǡ١xxxϴ¸ߤΤǺǤʤ)

ȡ顼ȤʤäƤޤ

ޤƱ͡ǡ١κphpMyAdminϤǤȥѥͥ뤫Ԥ

ǡ١κ

ʤȥѥͥ뤫ǡ١(MySQL)ϺǤ뤬Ǥ˾¤롣

饤ȡʤ
ɡ20
ץߥࡧ50
ӥͥ100
ӥͥץ200
ޥ͡ɥ(ͭ)̵

饤ȤMySQLȤʤΤǡMySQLȤʤ饹ɰʾˤ褦

ȤǤϾ20Ĥ20Ĥ⤢нʬ

ơ֥¿ΤǤ͡

񤤤饤󥿡ͥå(WEB)СDBСϡ̤ΥСǤ롣

饤󥿡ͥå(WEB)С餷DBСˤ³Ǥʤ

¾ҤΥ󥿥륵С顢DBСˤ³ǤʤΤ

꡼ƥ͡

ʲս꤫ԿʥϼǤǤ뤷ԿʥäȤƤ⡢ϤδǤ뤫()ǤƤ롣
[PR] au WALLETɤξ - auΥץڥɥɤǥåԥ󥰤򤪥ȥˡ

Υȥ꡼ϤƤʥ֥åޡɲ mixiå Share on Tumblr Clip to Evernote






DebianMySQLDBСȤĶ֤

СΩƤơü饢뤳ȤϤ褯뤳Ȥ

ǥեȤǤϡMySQLäüǤ뤬()¾üϥǤʤ

ǽˤˤϡMySQLäü(DBС)

/etc/mysql/my.cnf (MySQLե)

Խ롣

ʤDebian˸¤餺LinuxǤϡ/etcեǼǥ쥯ȥǤ롣

/etc/mysql/my.cnf



bind-address = 127.0.0.1

ȤҤΤǡ뤫Ƭ#(ȹ)դơ

# bind-address = 127.0.0.1

Ȥ

/etc/init.d/mysql restart

ǡMySQLκƵư

Ƶư塢DBС³Ǥ뤫ǧ롣

DzϤΤbind-addressϡ³MySQLưƤüIPɥ쥹Ǥꡢ³ĤIPɥ쥹ǤϤʤΤ

äơ³Ǥü䤽Ȥ

bind-address = 127.0.0.1

bind-address = 192.168.0.10

bind-address = 192.168.0.20

ʻƤ̣ʤȤ⤽̵

֤bind-address³ĤIPɥ쥹ǤϤʤ³ƤüIP¤ΤǤϤʤ

ʤMySQLäü(DBС)ApacheWEBСäƤꡢWEBСMySQL˥ϡʤΤDz⤹ɬפϤʤ

MySQLäü(DBС)ʣ椢ꡢơ¾إ褦ʾ⡢嵭ѹɬס

MySQLǽХ֥ ~ΩAtoZ~
MySQLǽХ֥ ~ΩAtoZ~
posted with amazlet at 14.06.01

ɾ
夲󥭥: 199,175

[PR] au WALLETɤξ - auΥץڥɥɤǥåԥ󥰤򤪥ȥˡ

Υȥ꡼ϤƤʥ֥åޡɲ mixiå Share on Tumblr Clip to Evernote






(ͳٹ)ȤȤ¿饤󥿡ͥåΥ桼Τǥ⡣





WEBСcsvե֤ơDB(MySQL)˥ݡȤ롣

phpMyAdminΥݡȵǽȤвǽphpץǼ¹Ԥ

ȤʤȡLOAD DATA LOCAL INFILEͤ롣

LOAD DATA INFILE
ݡDB륵Сcsvե뤬

LOAD DATA LOCAL INFILE
饤Ȥˤcsvե򥵡СDB

MySQLǽХ֥381ڡ

ξϭѲǽȻפ뤬csvեΤ륵С(WEBС)MySQLΤ륵С(DBС)̤ξ(饤󥿡ͥå)ϡˡǤԲǽǤϡ

ͥåȤĴ٤ȡȤʤäȤmysqlimportξ󤬤뤬Ʊ󥿥륵СȼԤǤ⡢DBΥС꤬ۤʤΤǡºݤϼʬǻƤߤʤȤʤʤ

ޤդա

ͭǤ⺣̵ȤȤ뤫

phpMyAdminǤΥݡȤǤϡ祵¤(Ĺ16MiB)

ʴΥ륵Сͳ٤ΤͤѹǤ󥿥륵СξϺ

Τ褦ʾ硢FTPcsvե夲ƤơʲˡDB˥ݡȤȤ褤

phpǥץ񤤤ƤȡޥǤʤƤ⤤͡

ʲ硣

csvեν

WEBС /home/aaa/www/ test.csv ֤

aaaϡ饤󥿡ͥåǤΥ̾

test.csvȤ

1,first
2,second
3,third
4,forth
5,fifth

Ȥ޶ڤδñʤΡ

DBν

mysql***.db.sakura.ne.jp - aaa_xxx - test

ˡʲΤ褦ʥơ֥(test)Ƥ

ơ֥

id int
name text

***ϡ饤󥿡ͥåƤ줿DBֹ档

aaa_xxxDB̾ɬaaa_ղäΤϡ饤󥿡ͥåλ͡

ơ֥̾ϡ

ޥɤ򵭤phpե¹

WEBСtest.csvƱǥ쥯ȥ

?PHP

$import = "mysqlimport -h mysql***.db.sakura.ne.jp -u aaa -p(ѥ) -L --fields-terminated-by=',' aaa_xxx /home/aaa/www/test.csv" ;
system($import) ;

?


Ȥphpե(import.phpȤ)֤¹ԡ

-h mysql***.db.sakura.ne.jpۥ
-u aaaDBѤΥ桼̾
-p(ѥ)DBѤΥѥɡ-p³(ڡʤ)񤯤
-Lե뤫ɤ߹४ץ
--fields-terminated-by=','csvեζʸϡ,(Ⱦѥ)
aaa_xxxDB̾
/home/aaa/www/test.csvcsvեξ

ȡ

aaa_xxx.test: Records: 5 Deleted: 0 Skipped: 0 Warnings: 0

ɽ졢ʲΤ褦˥ǡǼ롣

csvƤǼƤ
csvƤǼƤ

ơmysqlimportˤơDB̾λϤ뤬ơ֥̾λϤʤΤ

ȵ˻פtest.csvγĥҤäΤơ֥̾ʤΤ

Ĥޤꡢե뤬test.txtξ⡢testơ֥̾

ե̾ȥơ֥̾ۤʤϡ

import.phpɤȡǡɵפƤޤ

2ǼƤ
2ǼƤ

ɤˤϡ

--deleteݡȤ˥ơ֥ˤ

Υץɲä롣

ǡǼ˶ˤƤΤǡɵϲǤ롣

ʤ -D Ǥϥ顼Ȥʤ(顼ɽϤʤǼʤ)

--delete ʤʤ

--ץФ-άĤޤꡢ

--delete -D ƱդȤϴְäƤΤ

Ϣmysqlimport --help

phpեŪ˼¹ԤˤϡcronϿФ褤

cd /home/aaa/www ; /usr/local/bin/php test.php > /dev/null

test.phpΤǥ쥯ȥ ; PHPΥޥɥѥ ץ򵭤phpե ᡼

Ǹ /dev/null postmaster@aaa.sakura.ne.jp إ᡼ʤ˽񤯡

ơcron¹ԤǤ褦ˡtest.phpΥѡߥå755ꡣ

ϡꤷֳ֤֤ˡʤDB˳Ǽ뤫ǧ롣

᡼Ǥ Permission denied Υ顼 postmaster@aaa.sakura.ne.jp Τǡμ¤ưȤǧޤǤ /dev/null դʤ

cron5ĤޤǤǤʤ褦ȥѥͥ뤫ǤϤʤС³ޥɤǤС5İʾǽ

Ϣ饤󥿡ͥåȤCRON(1.CRON)

Ϣ饤󥿡ͥåȤCRON(2.CRON塼)





MySQLǽХ֥ ~ΩAtoZ~
MySQLǽХ֥ ~ΩAtoZ~
posted with amazlet at 14.05.23

ɾ
夲󥭥: 170,416
[PR] au WALLETɤξ - auΥץڥɥɤǥåԥ󥰤򤪥ȥˡ

Υȥ꡼ϤƤʥ֥åޡɲ mixiå Share on Tumblr Clip to Evernote

ΥڡΥȥåץ