Mac使用brew安裝mysql

前言:

因?yàn)橛胢ac開發(fā),很多工具不是很熟練,這里做個筆記,以防以后再次入坑!??!


用Homebrew進(jìn)行安裝

最近發(fā)現(xiàn)mac上一個神奇工具 Homebrew(包缺失管理),就像maven管理jar包的依賴一樣,Homebrew幫忙管理各種工具,真是太方便。Homebrew的常用指令

安裝mysql

brew install mysql

啟動mysql

mysql.server start

設(shè)置密碼:

mysql_secure_installation

運(yùn)行mysql_secure_installation會執(zhí)行幾個設(shè)置:

a)為root用戶設(shè)置密碼

b)刪除匿名賬號

c)取消root用戶遠(yuǎn)程登錄

d)刪除test庫和對test庫的訪問權(quán)限

e)刷新授權(quán)表使修改生效

feideMacBook-Air:~ fei$ 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

看看輸出的提示,剩下的該怎么操作其實(shí)brew提示的很清楚了?。?!

登陸mysql:mysql -u root -p
啟動mysql:brew services start mysql
停止mysql:brew services stop mysql

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容