[Mysql] ์‚ฌ์šฉ์ž์ƒ์„ฑ ๋ฐ ๊ถŒํ•œ
ยท
๐Ÿ“DB/๐Ÿฌ MySQL
Mysql์˜ ์‚ฌ์šฉ์ž๋Š” ์‚ฌ์šฉ์ž์˜ ๊ณ„์ •๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ์‚ฌ์šฉ์ž์˜ ์ ‘์†์ฃผ์†Œ๊นŒ์ง€ ๊ณ„์ •์˜ ์ผ๋ถ€๊ฐ€ ๋œ๋‹ค.Mysql์—์„œ ๊ณ„์ •์„ ์–ธ๊ธ‰ํ•  ๋•Œ๋Š” ํ•ญ์ƒ ์•„์ด๋””์™€ ํ˜ธ์ŠคํŠธ๋ฅผ ํ•จ๊ป˜ ๋ช…์‹œํ•ด์•ผํ•œ๋‹ค.% ๋ฌธ์ž๋Š” ๋ชจ๋“  ํ˜ธ์ŠคํŠธ๋ช…์„ ์˜๋ฏธํ•œ๋‹ค.์˜ˆ์‹œ1 ) 'test_id'@'127.0.0.1'์˜ˆ์‹œ2) 'test_id'@'%'  ๊ณ„์ •# ๋ชจ๋“  ๊ณ„์ • ํ™•์ธํ•˜๊ธฐSELECT user, host FROM mysql.user;# mysql ๊ธฐ๋ณธ ๋‚ด์žฅ ๊ณ„์ • ํ™•์ธํ•˜๊ธฐSELECT user, host FROM mysql.user WHERE user LIKE 'mysql.%'; # ์‚ฌ์šฉ์ž ์ƒ์„ฑCREATE USER '{์œ ์ €๋ช…}'@'%' IDENTIFIED BY '{๋น„๋ฐ€๋ฒˆํ˜ธ}';# ๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณ€๊ฒฝALTER USER '{์œ ์ €๋ช…}'@'%' IDENTIFIED BY '{์ƒˆ๋กœ์šด ๋น„๋ฐ€๋ฒˆ..
[Mysql] ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋ฐฑ์—… ๋ฐ ๋ณต์›&๋ณต์ œ
ยท
๐Ÿ“DB/๐Ÿฌ MySQL
๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋ฐฑ์—… ํŒŒ์ผ ๋งŒ๋“ค๊ธฐmysqldump -h {ํ˜ธ์ŠคํŠธ์ฃผ์†Œ} -u {์œ ์ €๋ช…} -p {DB๋ช…} --set-gtid-purged=OFF > {ํŒŒ์ผ๋ช…}.sql#์˜ˆ์‹œmysqldump -h 127.0.0.1 -u user_name -p test_database --set-gtid-purged=OFF > backup_test_database.sql  ๋ฐฑ์—… ํŒŒ์ผ๋กœ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์— ๋ฐ์ดํ„ฐ ์ฃผ์ž…ํ•˜๊ธฐmysql -h {ํ˜ธ์ŠคํŠธ์ฃผ์†Œ} -u {์œ ์ €๋ช…} -p {DB๋ช…}
[PostgreSQL] Mac๋ถ์—์„œ ์‚ฌ์šฉํ•˜๊ธฐ
ยท
๐Ÿ“DB/๐Ÿ˜ PostgreSQL
์„ค์น˜ brew install postgresql brew services start postgresql ์„ค์น˜ ํ™•์ธ postgres --version ์ ‘์† # ์ ‘์† psql postgres # ์‚ฌ์šฉ์ž ํ™•์ธ postgres=# \du
[MySQL] Memory allocation error: 1038 Out of sort memory, consider increasing server sort buffer size ์—๋Ÿฌ
ยท
๐Ÿ“DB/๐Ÿฌ MySQL
mysql์— ํ• ๋‹น๋œ sort_buffer_size๊ฐ€ ์ ์–ด์„œ ๋ฐœ์ƒํ•œ ์˜ค๋ฅ˜์ด๋‹ค. sort_buffer_size๋ฅผ ๋” ๋†’๊ฒŒ ํ• ๋‹นํ•ด์ฃผ๋ฉด ํ•ด๊ฒฐ๋œ๋‹ค.#mysql ์ ‘์†mysql -u root -p #sort buffer size ํ™•์ธshow GLOBAL variables like "sort_buffer_size";#sort buffer size ์„ค์ •SET GLOBAL sort_buffer_size = 256000000;
[MySQL] CRUD
ยท
๐Ÿ“DB/๐Ÿฌ MySQL
์‚ฝ์ž…INSERT INRO ํ…Œ์ด๋ธ”์ด๋ฆ„ (์ด๋ฆ„1, ์ด๋ฆ„2, ์ด๋ฆ„3) values('์ด๋ฆ„1์˜ ๊ฐ’', ์ด๋ฆ„2์˜ ๊ฐ’', '์ด๋ฆ„3์˜ ๊ฐ’');  ๊ฒ€์ƒ‰SELECT * FROM ํ…Œ์ด๋ธ”์ด๋ฆ„;SELECT ์ด๋ฆ„1, ์ด๋ฆ„2 FROM ํ…Œ์ด๋ธ”์ด๋ฆ„; SELECT * FROM ํ…Œ์ด๋ธ”์ด๋ฆ„ WHERE ์ด๋ฆ„1 = ์ด๋ฆ„1์˜๊ฐ’; SELECT * FROM ํ…Œ์ด๋ธ”์ด๋ฆ„ WHERE ์ด๋ฆ„1=์ด๋ฆ„1์˜๊ฐ’ OR ์ด๋ฆ„2=์ด๋ฆ„2์˜๊ฐ’; #๋‚ด๋ฆผ์ฐจ์ˆœ ์ •๋ ฌSELECT * FROM ํ…Œ์ด๋ธ”์ด๋ฆ„ ORDER BY (์ด๋ฆ„1) DESC;#์˜ค๋ฅธ์ฐจ์ˆœ ์ •๋ ฌSELECT * FROM ํ…Œ์ด๋ธ”์ด๋ฆ„ ORDER BY (์ด๋ฆ„1) ASC;  ์ˆ˜์ •UPDATE ํ…Œ์ด๋ธ”์ด๋ฆ„ SET ์ด๋ฆ„1='์ˆ˜์ •ํ• ๊ฐ’' WHERE ์ด๋ฆ„2=์ด๋ฆ„2์˜๊ฐ’;  ์‚ญ์ œDELETE FROM ํ…Œ์ด๋ธ”์ด๋ฆ„ WHERE ์ด๋ฆ„1=์ด๋ฆ„1์˜๊ฐ’;
[MySQL] ํ…Œ์ด๋ธ”
ยท
๐Ÿ“DB/๐Ÿฌ MySQL
ํ…Œ์ด๋ธ” ์ƒ์„ฑCREATE TABLE ์ด๋ฆ„ ( ์ด๋ฆ„1 ํƒ€์ž… NULL์—ฌ๋ถ€ ํŠน์ง• ์ด๋ฆ„2 ํƒ€์ž… NULL์—ฌ๋ถ€ ํŠน์ง•);  NOT NULL : ๋น„์–ด์žˆ์œผ๋ฉด ์•ˆ๋œ๋‹ค.NULL : ๋น„์–ด์žˆ์„์ˆ˜๋„ ์žˆ๋‹ค. AUTO_INCREMENT : 1๋ถ€ํ„ฐ 1์”ฉ ์ฆ๊ฐ€ํ•œ ๊ฐ’์„ ์ž๋™์œผ๋กœ ์ €์žฅํ•œ๋‹ค.   ํ…Œ์ด๋ธ” ๋ณด๊ธฐSHOW TABLES;  ํ…Œ์ด๋ธ” ์ž์„ธํžˆ ๋ณด๊ธฐdesc ํ…Œ์ด๋ธ”์ด๋ฆ„;  ํ…Œ์ด๋ธ” ์‚ญ์ œDROP TABLE ํ…Œ์ด๋ธ”์ด๋ฆ„;
[MySQL] Window์—์„œ ์ ‘์†ํ•˜๊ธฐ
ยท
๐Ÿ“DB/๐Ÿฌ MySQL
์ ‘์†ํ•˜๊ธฐ- Bitnami๋ฅผ ๋‹ค์šด๋ฐ›์œผ๋ฉด ์•ˆ์— ์žˆ์Œ.- Win + R ํ‚ค ๋ฅผ ๋ˆ„๋ฅด๊ณ  'cmd' ์ฐฝ ์—ด๊ธฐcd C:\Bitnami\wampstack-8.0.11-3\mariadb\bin (ํŒŒ์ผ ๊ฒฝ๋กœ)mysql -uroot -p (์ ‘์†ํ•˜๊ธฐ)  ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค, ํ…Œ์ด๋ธ” ํ™•์ธํ•˜๊ธฐ# ๋ฐ์ดํ„ฐ ๋ฒ ์ด์Šค ์ƒ์„ฑํ•˜๊ธฐCREATE DATABASE (์ด๋ฆ„) CHARACTER SET utf8 COLLATE utf8_general_ci;#๋ฐ์ดํ„ฐ ๋ฒ ์ด์Šค ํ™•์ธํ•˜๊ธฐshow databases;#๋ฐ์ดํ„ฐ ๋ฒ ์ด์Šค ์‚ฌ์šฉํ•˜๊ธฐuse (๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ด๋ฆ„);#ํ…Œ์ด๋ธ” ํ™•์ธํ•˜๊ธฐshow tables;