登录
原创

Mac Brew 安装 Mysql 5.7

发布于 2020-09-30 阅读 1283
  • MySQL
原创

MacBook安装Mysql

安装MySQL5.7版本

brew install mysql@5.7
echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc

设置密码

mysql_secure_installation

安装完后启动mysql

brew services start mysql@5.7

若服务未启动就会出现以下错误

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

若要关闭mysql

mysql.server stop

看到提示success则表示启动成功

Starting MySQL
. SUCCESS! 

现在登录mysql,默认情况下免密登录

mysql -u root

安装完提示

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 /usr/local,
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="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc

For compilers to find mysql@5.7 you may need to set:
  export LDFLAGS="-L/usr/local/opt/mysql@5.7/lib"
  export 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.31: 319 files, 232.4MB

评论区

DDwyane
22粉丝

我饿了,要睡觉了~

0

0

0

举报