새소식

반응형
Mac

[Mac] brew mysql 설치

  • -
반응형

MacOS에 Homebrew를 이용해서 mysql을 설치하는 방법을 정리해보겠습니다.

 

brew search mysql

(예시 화면에 mysql@5.7에 체크가 되어있는 이유는 현재 제 환경에 해당 버전이 설치되어있기 때문입니다)

화면에 나오는 버전 중에 원하는 버전 설치

 

brew install mysql@5.7

버전 선택없이 mysql만 입력한다면, 최신의 stable 한 버전이 설치됩니다.

설치 후에 나오는 로그 내용을 잘 확인하고 필요한 명령어가 있다면, 시키는 대로 실행하면 됩니다. 

 

We've installed your MySQL database without a root password. To secure it run:

    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:

    mysql -uroot

mysql@5.7 is keg-only, which means it was not symlinked into /opt/homebrew,

because this is an alternate version of another formula.

If you need to have mysql@5.7 first in your PATH, run:

  echo 'export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc

For compilers to find mysql@5.7 you may need to set:

  export LDFLAGS="-L/opt/homebrew/opt/mysql@5.7/lib"

  export CPPFLAGS="-I/opt/homebrew/opt/mysql@5.7/include"

To restart mysql@5.7 after an upgrade:

  brew services restart mysql@5.7

Or, if you don't want/need a background service you can just run:

  /opt/homebrew/opt/mysql@5.7/bin/mysqld_safe --datadir=/opt/homebrew/var/mysql

 

echo 'export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

 

mysql --version

 

  • mysql 실행
    • brew services start mysql
    • mysql.server start
  • mysql 재시작
    • brew services  restart mysql
  • mysql 종료
    • brew services stop mysql
    • mysql.server stop

etc

  • brew services list

 

 

반응형

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.