下载安装
点击Download可进入社区下载页面 ⬇️⬇️⬇️
官方默认下载最新版本,如果想要下载稳定版本一般用5.7.29
版本。下载后点击安装包进行安装,接下来就是一路next
安装完成好了。。
默认密码
安装完成之后,会出现以下小弹窗,弹窗中有自动默认的root密码 需要保存一下。
mac电脑中安装完成后mysql并不在应用程序里,而是存放在系统偏好设置中⬇️⬇️⬇️
点击MySQL则进入启动服务\停止服务位置。
添加环境变量
- 打开终端输入
open -e .bash_profile
。 - 在打开的文件中输入
export PATH=${PATH}:/usr/local/mysql/bin
。 command + S
- 保存文件,后关闭文件。- 在终端输入,
source .bash_profile
执行一下文件。
修改密码
- 登录
mysql
,输入命令mysql -uroot -p
。 - 输入刚才弹窗中保存的默认密码,回车登陆。
- 输入命令
FLUSH PRIVILEGES;
- 输入命令
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('你的新密码');
- 修改密码成功,重新登录。
navicat免激活版本下载地址分享:(个人网盘)
链接:https://pan.baidu.com/s/1ZgEFjcnsj5OY3YOHJ2lbQA
密码:n1mj
安全模式登陆
如果有报错:mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
描述:这个报错的意思是说因权限等原因拒绝了请求,通过一下方式解决问题。
- mac电脑请打开系统偏好设置,关闭mysql服务。
- 打开终端输入:
$ cd /usr/local/mysql/bin
$ sudo su
- 看到命令行头部改变之后,继续输入:
./mysqld_safe --skip-grant-tables &
- 不要关闭当前终端,在新建一个终端,输入:
/usr/local/mysql/bin/mysql
- 出现一下提示,则表示登陆成功
Your MySQL connection id is 433
Server version: 5.7.29 MySQL Community Server (GPL)
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>
- 登陆成功后输入
use mysql;
,然后输入以下命令修改密码:
mysql> update user set authentication_string=password('你的新密码') where Host='localhost' and User='root';
- 出现以下提示,则表示修改成功。
Query OK, 1 row affected, 1 warning (0.02 sec)
Rows matched: 1 Changed: 0 Warnings: 1
卸载
分别执行以下四条命令,之后系统偏好设置中的mysql小图标则会消失。
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*