homebrew๋กœ MySQL ํŒจํ‚ค์ง€ ์„ค์น˜ ๋ฐฉ๋ฒ•Permalink

MySQL ํŒจํ‚ค์ง€ ๊ฒ€์ƒ‰Permalink

> brew search mysql
==> Formulae
automysqlbackup               mysql-client                  mysql-sandbox                 mysql@5.7
mysql                         mysql-client@5.7              mysql-search-replace          mysqltuner
mysql++                       mysql-connector-c++           mysql@5.6                     qt-mysql
==> Casks
mysql-connector-python                  mysql-utilities                         navicat-for-mysql
mysql-shell                             mysqlworkbench โœ”                        sqlpro-for-mysql

MySQL ์„ค์น˜ ๋ฐฉ๋ฒ•Permalink

  • brew install mysql : ์ตœ์‹  mysql ํŒจํ‚ค์ง€๋ฅผ ๋‹ค์šด๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • brew install mysql@5.7 : mysql 5.7๋ฒ„์ „ ํŒจํ‚ค์ง€๋ฅผ ๋‹ค์šด๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

mysql@๋ฒ„์ „ : ์›ํ•˜๋Š” ๋ฒ„์ „์„ ์„ ํƒํ•˜์—ฌ ๋‹ค์šด๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

mysql@5.7์„ ์„ค์น˜ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

MySQL ์„ค์น˜ ํ™•์ธ ๋ฐฉ๋ฒ•Permalink

  • brew list๋ฅผ ํ†ตํ•ด ์„ค์น˜๋œ ํ•ญ๋ชฉ์„ ์กฐํšŒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
> brew list
mysql@5.7

MySQL ์‚ญ์ œ ๋ฐฉ๋ฒ•Permalink

  • brew remove mysql@5.7

brew list๋ฅผ ํ†ตํ•ด ์‚ญ์ œ๋˜์—ˆ๋Š”์ง€ ํ™•์ธ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

MySQL ์„ค์ • ๋ฐฉ๋ฒ•Permalink

ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ์ถ”๊ฐ€Permalink

  • bash shell์ด ์•„๋‹Œ zsh shell์„ ๊ธฐ์ค€์œผ๋กœ ์ž‘์„ฑํ•˜์˜€์Šต๋‹ˆ๋‹ค
> echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc

ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ์ ์šฉPermalink

> source ~/.zshrc

MySQL ์„œ๋ฒ„ ์‹คํ–‰/์ค‘์ง€Permalink

mysql.server start ๋ช…๋ น์–ด๋กœ MySQL ์„œ๋ฒ„๋ฅผ ์‹คํ–‰์‹œํ‚ต๋‹ˆ๋‹ค.

> mysql.server start
Starting MySQL
 SUCCESS!

mysql.server stop ๋ช…๋ น์–ด๋กœ MySQL ์„œ๋ฒ„๋ฅผ ์ค‘์ง€์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

MySQL ์„ค์ •Permalink

MySQL ์„ค์ •์„ ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” mysql_secure_installation ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD PLUGIN 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 plugin?

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

๋น„๋ฐ€๋ฒˆํ˜ธ ์œ ํ˜• ์„ ํƒPermalink

๋น„๋ฐ€๋ฒˆํ˜ธ ๊ฐ€์ด๋“œ ์„ค์ •์— ๋Œ€ํ•œ ์งˆ๋ฌธ์ž…๋‹ˆ๋‹ค.

  • Yes : ๋ณต์žกํ•œ ๋น„๋ฐ€๋ฒˆํ˜ธ ์„ค์ •
  • No : ์‰ฌ์šด ๋น„๋ฐ€๋ฒˆํ˜ธ ์„ค์ •
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

No๋ฅผ ์„ ํƒํ–ˆ์Šต๋‹ˆ๋‹ค.

๋น„๋ฐ€๋ฒˆํ˜ธ ์„ค์ •Permalink

์‚ฌ์šฉํ•  ์ƒˆ๋กœ์šด ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

Please set the password for root here.

New password:

Re-enter new password:

๋น„๋ฐ€๋ฒˆํ˜ธ๋Š” ๊ฐ„๋‹จํ•˜๊ฒŒ mysql๋กœ ํ–ˆ์Šต๋‹ˆ๋‹ค.

์‚ฌ์šฉ์ž ์„ค์ •Permalink

Remove anonymous users? (Press y|Y for Yes. any other key for No)
์‚ฌ์šฉ์ž ์„ค์ •์„ ํ•˜๋Š” ๋ถ€๋ถ„์ž…๋‹ˆ๋‹ค.

  • Yes : ์ ‘์†ํ•˜๋Š” ๊ฒฝ์šฐ mysql -u root์ฒ˜๋Ÿผ -u ์˜ต์…˜ ํ•„์š”
  • No : ์ ‘์†ํ•˜๋Š” ๊ฒฝ์šฐ mysql์ฒ˜๋Ÿผ -u ์˜ต์…˜ ๋ถˆํ•„์š”
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) : Yes

Yes๋ฅผ ์„ ํƒํ–ˆ์Šต๋‹ˆ๋‹ค.

์›๊ฒฉ ์ ‘์† ์„ค์ •Permalink

Disallow root login remotely? (Press y|Y for Yes, any other key for No)
๋‹ค๋ฅธ IP์—์„œ root ์•„์ด๋””๋กœ ์›๊ฒฉ์ ‘์†์„ ํ—ˆ์šฉํ•˜๋Š”์ง€์— ๋Œ€ํ•œ ์„ค์ •์ž…๋‹ˆ๋‹ค.

  • Yes : ์›๊ฒฉ์ ‘์† ๋ถˆ๊ฐ€๋Šฅ
  • No : ์›๊ฒฉ์ ‘์† ๊ฐ€๋Šฅ
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) : No

Yes๋ฅผ ์„ ํƒํ–ˆ์Šต๋‹ˆ๋‹ค.

TEST ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์„ค์ •Permalink

Remove test database and access to it? (Press y|Y for Yes, any other key for No)
Test ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ์„ค์ •ํ•˜๋Š” ์งˆ๋ฌธ์ž…๋‹ˆ๋‹ค

  • Yes : Test ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ œ๊ฑฐ
  • No : Test ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์œ ์ง€
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) : Yes

Yes๋ฅผ ์„ ํƒํ–ˆ์Šต๋‹ˆ๋‹ค.

๋ณ€๊ฒฝ๋œ ๊ถŒํ•œ์„ ํ…Œ์ด๋ธ”์— ์ ์šฉํ•˜๋Š” ์„ค์ •Permalink

Reload privilege tables now? (Press y|Y for Yes, any other key for No)
๋ณ€๊ฒฝ๋œ ๊ถŒํ•œ์„ ํ…Œ์ด๋ธ”์— ์ ์šฉํ•˜๋Š” ์„ค์ •์— ๋Œ€ํ•œ ์งˆ๋ฌธ์ž…๋‹ˆ๋‹ค.

  • Yes : ์ ์šฉ ์‹œํ‚จ๋‹ค
  • No : ์ ์šฉ์‹œํ‚ค์ง€ ์•Š๋Š”๋‹ค
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

Yes๋ฅผ ์„ ํƒํ–ˆ์Šต๋‹ˆ๋‹ค.

์„ค์ • ์™„๋ฃŒPermalink

  • All done!์ด ๋œจ๋ฉด ๋ชจ๋“  ์„ค์ •์ด ๋์ž…๋‹ˆ๋‹ค.

MySQL DB ๋กœ๊ทธ์ธ/๋กœ๊ทธ์•„์›ƒPermalink

mysql -uroot -p ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ›„ ์œ„์—์„œ ์„ค์ •ํ•œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ›„ ๋กœ๊ทธ์ธํ•ฉ๋‹ˆ๋‹ค.

> mysql -uroot -p
Enter password:
  • ์ •์ƒ์ ์œผ๋กœ ๋กœ๊ทธ์ธ์ด ๋˜๋ฉด mysql> ๋‚˜์˜ต๋‹ˆ๋‹ค.
> mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.35 Homebrew

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

mysql> ์‰˜์—์„œ exit or quit ๋ช…๋ น์–ด๋กœ ๋กœ๊ทธ์•„์›ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

mysql> exit or quit
Bye

MySQL ์‹คํ–‰ ์ ˆ์ฐจPermalink

  1. MySQL ์„œ๋ฒ„ ์‹œ์ž‘ : mysql.server start
  2. MySQL DB ๋กœ๊ทธ์ธ : mysql -uroot -p
  3. MySQL DB ๋กœ๊ทธ์•„์›ƒ : exit ๋˜๋Š” quit
  4. MySQL ์„œ๋ฒ„ ์ข…๋ฃŒ : mysql.server stop

referencePermalink

macOS MySQL ์„ค์น˜ ๋ฐ ์„ค์ • ์‚ฌ์šฉ๋ฒ•
MySQL ์„ค์น˜์™€ ์ดˆ๊ธฐ ์„ค์ • for macOS
MacOS brew๋กœ mysql5.7 ์„ค์น˜
mysql5.7 ๋ฒ„์ „ homebrew ๋กœ ์„ค์น˜