MAC brew安装 mysql

2019年6月11日 作者 ruike

一、安装

CatowoMacbookPro: brew install mysql@5.7
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/mysql@5.7-5.7.23.high_sierra.
Already downloaded: /Users/fei/Library/Caches/Homebrew/mysql@5.7-5.7.23.high_sierra.bottle.tar.gz
==> Pouring mysql@5.7-5.7.23.high_sierra.bottle.tar.gz
==> /usr/local/Cellar/mysql@5.7/5.7.23/bin/mysqld --initialize-insecure --user=fei
==> Caveats
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

This formula is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/mysql@5.7/lib
    CPPFLAGS: -I/usr/local/opt/mysql@5.7/include


To have launchd start mysql@5.7 now and restart at login:
  brew services start mysql@5.7
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/mysql@5.7/bin/mysql.server start
==> Summary
🍺  /usr/local/Cellar/mysql@5.7/5.7.23: 317 files, 234.4MB

二、配置:

  • 根据提示,先将mysql加入path:
    echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile

  • 起一个新的终端,启动mysql服务

mysql.service start

  • 配置密码:

mysql_secure_installation

三、使用

mysql -uroot -p

mysql.service start
mysql.service stop