Mac OX 配置 MySQL 5.7.17

该博文讲解如何在Mac下配置MySQL 5.7.17

下载安装包

https://www.mysql.com/downloads/

选择community选项卡

选择community server

MySQL Community Server (GPL)
(Current Generally Available Release: 5.7.17)

下载

Mac OS X 10.12 (x86, 64-bit), DMG Archive 选择这个 ,下载

千万!不要!点!注册!(那两个大大的按钮,不要点击!)直接点击下方的小字:No thanks, just start my download.

安装

记录密码

下载了mysql-5.7.17-macos10.12-x86_64.dmg之后,双击安装,按照提示一步步安装好

最后成功的时候会弹出一个提示框!!!内容如下:

2017-04-04T15:19:29.515727Z 1 [Note] A temporary password is generated for root@localhost: &8qjd%(aBdw4

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

其中被划线的部分是我手工画上去的,一定要复制这几个字!是之后要用的密码!如果忘记了,又得重新卸载再重装一遍,很麻烦!

偏好设置

打开mac -> 偏好设置 ->看到最底下多了一个mysql,打开

看到已经启动(默认启动)

配置环境变量

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

修改密码

1
mysql -u root -p

这时候会让你输入密码,就是输入刚刚保存的那个原始密码,复制进去,回车,进入~

1
2
3
4
5
6
7
8
9
Copyright (c) 2000, 2016, 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>SET PASSWORD = PASSWORD('new password');

输入最后那一句,把“new password” 换成自己想换的新密码即可~

卸载

如果忘记了初始密码,或者出现各种打不开之类的问题,最省事的方法就是。。。卸载重装。。

卸载方式如下:(如果正在运行mysql,则停止),然后在终断执行:

1
2
3
4
5
6
7
8
9
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*

然后重复上面的安装步骤,希望一切就会顺利起来~

参考文档

http://www.jb51.net/article/103502.htm

http://www.cnblogs.com/dandanlovehamhamzo/p/4963427.html