๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ“ŒCS/DB

[MySQL] MySQL ๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณ€๊ฒฝ ๋ฐฉ๋ฒ•

by dar0m! 2019. 5. 22.

(1) MySQL ์ ‘์†ํ•˜๊ธฐ

cmd๋ฅผ ์‹คํ–‰ํ•˜๊ณ  ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜๊ณ  ์ด์ „ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.
$ mysql -u root -p

Enter password:
mysql -u ๋’ค์—๋Š” ์‚ฌ์šฉ์ž๋ช…, -p ๋Š” ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์‚ฌ์šฉํ•˜๊ฒ ๋‹ค๋Š” ๋œป์ž…๋‹ˆ๋‹ค.
๋น„๋ฐ€๋ฒˆํ˜ธ ์ž…๋ ฅ ์ฐฝ์ด ๋œจ๋ฉด MySQL ์„ค์น˜ ์‹œ ์„ค์ •ํ–ˆ๋˜ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

 

(2) ๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณ€๊ฒฝ์„ ์œ„ํ•ด mysql ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์‚ฌ์šฉ

ํ”„๋กฌํ”„ํŠธ๊ฐ€ mysql> ๋กœ ๋ฐ”๋€Œ์—ˆ๋‹ค๋ฉด ์ ‘์†๋œ ๊ฒƒ์ž…๋‹ˆ๋‹ค.
mysql> use mysql;



Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A



Database changed

 

(3) ํ˜„์žฌ ์•”ํ˜ธ ํ™•์ธ

์ฐจ๋ก€๋Œ€๋กœ host, user ์ •๋ณด์™€ ์•”ํ˜ธํ™”๋œ ๋น„๋ฐ€๋ฒˆํ˜ธ ํ™•์ธ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.
mysql> select host, user, authentication_string from user;

 

(4) ๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณ€๊ฒฝ

root ๊ณ„์ •์˜ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ nodejs ๋กœ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค.

mysql> update user set authentication_string=password('nodejs') where user='root';

 

(5) ์ข…๋ฃŒ

๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ์ ์šฉํ•˜๊ธฐ ์œ„ํ•ด ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•œ ํ›„ ์ข…๋ฃŒํ•˜๋ฉด ๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณ€๊ฒฝ์ด ์™„๋ฃŒ๋ฉ๋‹ˆ๋‹ค.

mysql> flush privileges;

mysql> quit 

Bye
flush privileges ๋Š” ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ๋ฐ˜์˜ํ•˜๊ธฐ ์œ„ํ•˜์—ฌ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
๋ณดํ†ต์€ INSERT, DELETE, UPDATE๋ฅผ ํ†ตํ•ด ์‚ฌ์šฉ์ž๋ฅผ ์ถ”๊ฐ€, ์‚ญ์ œ, ๊ถŒํ•œ ๋ณ€๊ฒฝ ๋“ฑ์„ ์ˆ˜ํ–‰ํ•˜์˜€์„ ๋•Œ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ์ฆ‰์‹œ ๋ฐ˜์˜ํ•˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.

'๐Ÿ“ŒCS > DB' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[DB] N + 1 ๋ฌธ์ œ  (0) 2021.04.11
[DB] Index  (1) 2021.04.04
[SQL] ๋‹ค์ค‘์ •๋ ฌ ORDER BY  (1) 2020.01.09
[MySQL] Resotre Workspace ์˜ค๋ฅ˜  (0) 2019.12.10
[Sequelize v5] ์‹œํ€„๋ผ์ด์ฆˆ find ํ•จ์ˆ˜ ์˜ค๋ฅ˜  (0) 2019.05.29

๋Œ“๊ธ€