mac安装mysql5.7

引言

搭建Python练习环境需要mysql,在mac上安装。

正文

  1. Mysql官网下载安装包:
    安装包
  2. 打开安装包,只有一个.pkg文件,运行并逐步安装,完成时会提示临时密码,如下:
    记住临时密码
  3. 然后到系统偏好设置,最下方找到MySQL,Start MySQL Server
  4. 跳转到/usr/local/mysql/bin路径下,修改临时密码
# milletluo @ bogon in /usr/local/mysql/bin [15:13:00] 
$ ./mysqladmin -u root -p password
Enter password: 
New password: 
Confirm new password: 
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
  1. 在该目录下使用新密码即可登录
# milletluo @ bogon in /usr/local/mysql/bin [15:16:19] C:127
$ ./mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.7.17 MySQL Community Server (GPL)
  1. 为了在任意目录下启动MySQL,需要将上述目录加入全局变量
# milletluo @ bogon in ~ [15:22:37] 
$ vim .bash_profile

//添加export PATH=$PATH:/usr/local/mysql/bin

# milletluo @ bogon in ~ [15:24:49] 
$ source .bash_profile

注意:由于我使用的是zsh,确保.zshrc中添加了source ~/.bash_profile或直接将全局变量添加进.zshrc

  1. 附:macOS全局变量
    Mac系统的环境变量,加载顺序为:
    /etc/profile > /etc/paths > ~/.bash_profile > ~/.bash_login > ~/.profile > ~/.bashrc
    当然/etc/profile和/etc/paths是系统级别的,系统启动就会加载,后面几个是当前用户级的环境变量。后面3个按照从前往后的顺序读取,如果~/.bash_profile文件存在,则后面的几个文件就会被忽略不读了,如果~/.bash_profile文件不存在,才会以此类推读取后面的文件。~/.bashrc没有上述规则,它是bash shell打开的时候载入的。

参考

MAC 设置环境变量path的几种方法

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值