ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

DEV TIP

[MySQL] MySQL ์„ค์น˜ for Mac

NakyungIm 2022. 1. 18. 22:11

์ด๋ฏธ์ง€ ์ถœ์ฒ˜ : https://namu.wiki/w/MySQL

 

 

mac์—์„œ homebrew๋ฅผ ์ด์šฉํ•˜์—ฌ MySQL์„ ์„ค์น˜ํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

 

homebrew ์„ค์น˜

์ €๋Š” homebrew๊ฐ€ ์„ค์น˜๋˜์–ด ์žˆ์ง€๋งŒ, ์„ค์น˜๊ฐ€ ์•ˆ๋˜์–ด์žˆ๋Š” ๋ถ„๋“ค์€ ์•„๋ž˜ ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ•ด์ฃผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

https://brew.sh/index_ko

 

Homebrew

The Missing Package Manager for macOS (or Linux).

brew.sh

 

 

homebrew ์—…๊ทธ๋ ˆ์ด๋“œ

homebrew๋ฅผ ์—…๊ทธ๋ ˆ์ด๋“œํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

๋‘ ๊ฐ€์ง€๊ฐ€ ์žˆ์–ด์„œ ์ฐจ๋ก€๋กœ ์ž‘์„ฑํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

1. brew update ํ•œ ๋’ค brew upgrade

 

2. brew upgrade ๋งŒ ํ•˜๊ธฐ

(brew upgrade๋Š” brew update๋ฅผ ํฌํ•จํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.)

 

 

MySQL ์„ค์น˜

brew install mysql

 

 

๋ฒ„์ „ ํ™•์ธ

mysql -V

 

 

์„œ๋ฒ„ ์ผœ๊ธฐ

mysql.server start

 

 

์ดˆ๊ธฐ ์„ค์ •

mysql_secure_installation

 

๋”๋ณด๊ธฐ

VALIDATE PASSWORD COMPONENT can be used to test passwords

and improve security. It checks the strength of password

and allows the users to set only those passwords which are

secure enough. Would you like to setup VALIDATE PASSWORD component?

 

Press y|Y for Yes, any other key for No: 

๋ธ”๋ก ์•ˆ์˜ ๋ช…๋ น์–ด๋ฅผ ์น˜๋ฉด ์œ„์™€๊ฐ™์ด ๋‚˜์˜ต๋‹ˆ๋‹ค.

๋ณต์žกํ•œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์„ค์ •ํ•œ ๊ฒƒ์ธ์ง€ ๋ฌผ์–ด๋ณด๋Š”๋ฐ, ์ €๋Š” No๋ฅผ ์„ ํƒํ–ˆ์Šต๋‹ˆ๋‹ค.

 

๊ทธ ๋‹ค์Œ ๋น„๋ฐ€๋ฒˆํ˜ธ์™€ ๋น„๋ฐ€๋ฒˆํ˜ธ ํ™•์ธ์„ ์ง„ํ–‰ํ•˜๋ฉด ๋‹ค์Œ์ฒ˜๋Ÿผ ๋‚˜์˜ต๋‹ˆ๋‹ค.

 

๋”๋ณด๊ธฐ

By default, a MySQL installation has an anonymous user,

allowing anyone to log into MySQL without having to have

a user account created for them. This is intended only for

testing, and to make the installation go a bit smoother.

You should remove them before moving into a production

environment.

 

Remove anonymous users? (Press y|Y for Yes, any other key for No) : 

default๋กœ ์„ค์ •๋˜๋Š” anonymous users๋ฅผ ์ œ๊ฑฐํ• ๊ฑด์ง€ ๋ฌผ์–ด๋ด…๋‹ˆ๋‹ค. ์ œ๊ฑฐ๋ฅผ ํ•˜๋ ค๋ฉด y๋ฅผ ๋ˆŒ๋Ÿฌ์ค๋‹ˆ๋‹ค.

 

๋”๋ณด๊ธฐ

Normally, root should only be allowed to connect from

'localhost'. This ensures that someone cannot guess at

the root password from the network.

 

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : 

root ์ ‘์†์„ localhost์—์„œ๋งŒ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•  ์ง€, ์™ธ๋ถ€์—์„œ๋„ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ• ์ง€ ๋ฌผ์–ด๋ด…๋‹ˆ๋‹ค.

์™ธ๋ถ€์—์„œ root ์ ‘์†์„ ๋ถˆ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•˜๋ ค๋ฉด Yes, ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•˜๋ ค๋ฉด No๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค. ์ €๋Š” Yes๋กœ ํ–ˆ์Šต๋‹ˆ๋‹ค!

 

๋”๋ณด๊ธฐ

By default, MySQL comes with a database named 'test' that

anyone can access. This is also intended only for testing,

and should be removed before moving into a production

environment.

 

 

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : 

test database๋ฅผ ์‚ญ์ œํ• ๊ฑด์ง€ ๋ฌผ์–ด๋ด…๋‹ˆ๋‹ค. yes๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์—ˆ์Šต๋‹ˆ๋‹ค.

 

๋”๋ณด๊ธฐ

Reloading the privilege tables will ensure that all changes

made so far will take effect immediately.

 

Reload privilege tables now? (Press y|Y for Yes, any other key for No) :

๋ณ€๊ฒฝ๋œ ๊ถŒํ•œ์„ ํ…Œ์ด๋ธ”์— ์ ์šฉํ• ๊ฑด์ง€ ๋ฌผ์–ด๋ด…๋‹ˆ๋‹ค. ๋ฌด์กฐ๊ฑด Yes๋กœ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.

 

 

์ดˆ๊ธฐ ๋ณด์•ˆ ์„ค์ • ๋!!

 

 

MySQL ์ ‘์†

mysql -u root -p

์œ„ ๋ช…๋ น์–ด ์ž…๋ ฅ ํ›„ ์กฐ๊ธˆ ์ „ ๋ณธ์ธ์ด ์„ค์ •ํ•œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

์ฐธ๊ณ ๋กœ ๋น„๋ฐ€๋ฒˆํ˜ธ ์ž…๋ ฅ ์‹œ ํ™”๋ฉด์—๋Š” ์•„๋ฌด๊ฒƒ๋„ ๋œจ์ง€ ์•Š๋Š” ๊ฒƒ์ด ์ •์ƒ์ž…๋‹ˆ๋‹ค!

 

>mysql ์•ž์— ์ด๋ ‡๊ฒŒ ๋œจ๋ฉด ์ •์ƒ์ ์œผ๋กœ ์ ‘์†๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

 

MySQL ์ข…๋ฃŒ

exit

 

 

์„œ๋ฒ„ ์ข…๋ฃŒ

mysql.server stop
๋Œ“๊ธ€