引言
搭建Python练习环境需要mysql,在mac上安装。
正文
Mysql官网下载安装包: 打开安装包,只有一个.pkg文件,运行并逐步安装,完成时会提示临时密码,如下: 然后到系统偏好设置,最下方找到MySQL,Start MySQL Server跳转到/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.
在该目录下使用新密码即可登录
$ ./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)
为了在任意目录下启动MySQL,需要将上述目录加入全局变量
$ vim .bash_profile
//添加
export PATH=
$PATH:/usr/local/mysql/bin
$
source .bash_profile
注意:由于我使用的是zsh,确保.zshrc中添加了source ~/.bash_profile或直接将全局变量添加进.zshrc
附: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的几种方法
转载请注明原文地址: https://ju.6miu.com/read-36172.html