[Mac] MySQL Community Server 8.0.21 安装

官方下载地址

步骤1:下载

 

 

步骤2:安装

下载下来之后直接双击安装

可能会出现【无法打开“mysql-8.0.21-macos10.15-x86_64.pkg”,因为Apple无法检查其是否包含恶意软件。】

解决方法:设置 - 安全性与隐私

接下来一直下一步【注意中间弹出输入密码操作,设置好密码,请记住,后面登陆需要】

安装完成后,设置的系统偏好界面下方有个MySQL标志。

【启动】点击这标记,勾选Start MySQL when your computer starts up

 

步骤3:环境添加

1、首先打开终端,使用mysql,发现command not found,这是因为我们没配置系统的环境变量,下面我们来进行配置:

Last login: Mon Oct  5 20:13:44 on ttys000
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
bin$ mysql
-bash: mysql: command not found

2、因此需要到安装目录下 cd /usr/local/mysql/bin,然后输入pwd确认一下自己当前是处于这个目录下

bin$ cd /usr/local/mysql/bin
bin$ pwd
/usr/local/mysql/bin

3、输入vim ~/.bash_profile

bin$ vim ~/.bash_profile

4、在弹出的文件中输入以下三句【进去后点击字母键I进行insert模式,然后在空白行插入,插入完成后,按esc推出insert模式,接着按住shift + :,然后输入wq退出文件 】

export PATH=$PATH:/usr/local/mysql/bin
alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin

5、输入source ~/.bash_profile让刚才的配置立即生效

bin$ source ~/.bash_profile

6、输入mysql -u root -p登陆mysql,这里的密码就是安装时候输入的【注意:输入的密码时候没有字符显示】

bin$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.21 MySQL Community Server - GPL
Copyright (c) 2000, 2020, 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>

至此,大功告成!

【可选】7、如果觉得密码不合适,进入mysql后使用set password for root@localhost=password('xxxxxx');更改密码

8、输入 quit,退出 MySQL。

 

【可选】步骤4

如果觉得命令行操作不方便,也可以使用可视化软件,例如navicat

 

参考资料:

https://www.jianshu.com/p/199492627ccc

https://blog.csdn.net/WinstonLau/article/details/81323340

https://blog.csdn.net/xiaotao131/article/details/102581459

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值