brew 工具,如果没有的话
1 | # 安装 homebrew,是的你没看错,在终端里粘贴以下命令即可 |
查看mysql包情况
查看当前最新稳定包
brew info mysql
- MYSQL的版本
- 它存在一些冲突包,没有办法和他们共存
- 安装后默认是没有密码的,如果你想安全一点,可以执行
mysql_secure_installation
来进行引导安全设置 - 你可以将MYSQL设置为开机启动,
brew services start mysql
- 你也可以每次都手动启动或关闭MYSQL
mysql.server start/stop/restart
查看当前包信息
brew search mysql
安装mysql
brew install mysql
可以在mysql后面跟指定版本mysql@5.7
- 如果遇到权限问题,会有提示,按照提示完成
1
2sudo chown -R $(whoami) /usr/local/share/man/man5 /usr/local/share/man/man7
chmod u+w /usr/local/share/man/man5 /usr/local/share/man/man
MYSQL使用
- 重启
brew service restart mysql
- 设置为开机启动
brew services start mysql
- 关闭
brew services stop mysql
- 手动启动或关闭
mysql.server start/stop/restart
- 查看状态
brew services list
1
2Name Status User Plist
mysql started afacode /Users/..../Library/LaunchAgents/homebrew.mxcl.mysql.plist设置密码
mysql_secure_installation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22Press y|Y for Yes, any other key for No: y //使用密码验证
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0 // 选择密码验证等级
New password: // 输入新密码
Re-enter new password:
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y //是否希望继续提供密码保护
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y //删除匿名用户
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n // 是否禁止远程登录
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n // 是否删除测试库
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y // 刷新数据库权限
登陆
mysql -uroot -p
show databases;
use mysql;
show tables;
exit;
navicat连接
报错 2059 - Authentication plugin 'caching_sha2_password' cannot be loaded dlope
2059 - Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(../Frameworks/caching_sha2_password.so, 2): image not found
解决方法
1 | ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '密码'; |