前言:
因为用mac开发,很多工具不是很熟练,这里做个笔记,以防以后再次入坑!!!
用Homebrew进行安装
最近发现mac上一个神奇工具 Homebrew(包缺失管理),就像maven管理jar包的依赖一样,Homebrew帮忙管理各种工具,真是太方便。Homebrew的常用指令。
安装mysql
brew install mysql
启动mysql
mysql.server start
设置密码:
mysql_secure_installation
运行mysql_secure_installation会执行几个设置:
a)为root用户设置密码
b)删除匿名账号
c)取消root用户远程登录
d)删除test库和对test库的访问权限
e)刷新授权表使修改生效
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
看看输出的提示,剩下的该怎么操作其实brew提示的很清楚了!!!
登陆mysql:mysql -u root -p
启动mysql:brew services start mysql
停止mysql:brew services stop mysql
网友评论