개발

Install mysql on MAC OS.

cozynow 2018. 1. 16. 23:52

brew 를 통해서 설치하는 방법


Mysql install
  1. installed mysql with brew install mysql
brew update
brew install mysql

brew install mysql56

  1. ran the commands brew suggested: (see note: below)
    unset TMPDIR

    mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
  • mysql_install_db --verbose --user=whoami--basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
  1. Start mysql with mysql.server start command, to be able to log on it
  2. Used the alternate security script:
    /usr/local/Cellar/mysql/5.5.10/bin/mysql_secure_installation
  3. Followed the launchctl section from the brew package script output such as,
    #start
    launchctl load -w ~Library/LaunchAgents/homebrew.mxcl.mysql.plist
    launchctl load -w /usr/local/opt/mysql/homebrew.mxcl.mysql.plist
    #stop
    launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
launchctl unload -w /usr/local/opt/mysql/homebrew.mxcl.mysql.plist

계정 생성
UPDATE user SET Password=PASSWORD('MyNewPass') WHERE User='root'; 
FLUSH PRIVILEGES;



MySQL 5.7.6 and later:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

MySQL 5.7.5 and earlier:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
FLUSH PRIVILEGES;

4. PATH 추가
/usr/local/opt/mysql/bin

실행
mysql.server start




Mysql uninstall

Step-by-step:
brew remove mysql

brew cleanup --force


launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

sudo rm -rf /usr/local/var/mysql