1

安装

登陆MYSQL官网 ,注意下载5.7版本,不登陆直接下载文件。

记住临时密码

下载完成后,双击打开一路确定,但是当弹出一个MYSQL Installer提示框的时候一定打开备忘录复制粘贴记下弹出框的密码

2019-03-12T01:42:11.344785Z 1 [Note] A temporary password is generated for root@localhost: ZulSd!;yn2,G

If you lose this password, please consult the section How to Reset the Root Password in the MySQL reference manual.

打开MySQL服务

1、进入系统偏好设置

clipboard.png

2、点击MySQL

clipboard.png

3、开启MySQL服务

clipboard.png

配置路径

clipboard.png

vim ~/.bash_profile

加入

PATH=$PATH:/usr/local/mysql/bin

并保存(vim 中先按 Esc键,在输入 :wq )

实际操作后如下:

export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mysql/bin
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
~                       

再执行source ~/.bash_profile

登陆

命令行输入:

mysql -u root -p
//这是安装时候保存的信息  输入密码(ZulSd!;yn2,G)
2019-03-12T01:42:11.344785Z 1 [Note] A temporary password is generated for root@localhost: ZulSd!;yn2,G

If you lose this password, please consult the section How to Reset the Root Password in the MySQL reference manual.

登陆,输入之前保存的密码,进入后,再操作修改密码

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');

备注:也可以在命令行安装,在命令行中输入brew install mysqlbrew 包管理工具会自行安装 MySQL.


双子城
46 声望6 粉丝

just do it!