1. 下载想要的版本
image.png我下载的是
dmg
的
2. 安装mysql,保存密码!
image.png点击继续默认安装就可以
image.png安装完成后会出现一个弹窗,不要关闭,这个弹窗上有root用户的密码,先复制保存
如:我安装完成后的密码如下
- root@localhost: vhpuv4X/ByB6
3. 配置mysql
(1) 进入系统偏好设置
image.png(2)启动mysql服务
image.png开机自启看个人需要
点击Start MySqQl Server
启动服务
(3)将mysql加入环境变量
- 执行:
vim ~/.bash_profile
- 加入:
export PATH=$PATH:/usr/local/mysql/bin
- 退出编辑后终端输入
source ~/.bash_profile
4. 登录mysql
密码就是刚才安装完成弹窗提示的密码
mysql -uroot -p
输入密码后有如下提示说明登录成功:
daiyunzhoudeMacBook-Pro:mysql daiyunzhou$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 63
Server version: 5.7.20
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
5. 更新密码
不修改密码不能用其他工具链接,只能在终端通过
mysql -uroot -p
登录(这是本人测试的结果,如果不对希望各位大佬提出宝贵的意见)
- 修改密码
SET PASSWORD = PASSWORD('新密码');
- 选择性设置密码永不过期(可选)
ALTER USER 'root' PASSWORD EXPIRE NEVER
3. 刷新
```sh
flush privileges
如下图所示
```sh
mysql> SET PASSWORD = PASSWORD('这是我的密码,你不要看了')
-> ALTER USER 'root' PASSWORD EXPIRE NEVER
-> flush privileges
->
6. 通过sequel pro
工具连接
(1) 下载应用
(2) 安装应用
默认安装即可
安装完成打开如下所示:
image.png
网友评论