Mac系统 MySQL安装配置环境变量
Posted LQS_Android
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mac系统 MySQL安装配置环境变量相关的知识,希望对你有一定的参考价值。
去社区下载安装包,一直next知道安装完成:
mysql社区:https://dev.mysql.com/downloads/mysql/
1)查看mysql
是否安装成功
我们在终端输入mysql
,发现提示commod not found
,那是因为我们没配置系统的环境变量,下面我们来进行配置:
2)在终端加入环境路径
- 如果是
bash
,执行open ~/.bash_profile
;如果是zsh
,执行open ~/.zshrc
- 添加语句
PATH=$PATH:/usr/local/mysql/bin
,保存(看我下面演示) - 立即生效,
source ~/.bash_profile
或者source ~/.zshrc
(3) 在终端输入下面命令,输入密码登录mysql
mysql -uroot -p
Last login: Wed Sep 8 09:03:29 on console
Apple-MacBook-pro:~ apple$ mysql
-bash: mysql: command not found
Apple-MacBook-pro:~ apple$ open ~/.bash_profile
Apple-MacBook-pro:~ apple$ source ~/.bash_profile
Apple-MacBook-pro:~ apple$ mysql
ERROR 1045 (28000): Access denied for user 'apple'@'localhost' (using password: NO)
Apple-MacBook-pro:~ apple$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \\g.
Your MySQL connection id is 9
Server version: 8.0.12 MySQL Community Server - GPL
Copyright (c) 2000, 2018, 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>
Mac系统中追加环境变量PATH的语法格式:
设置PATH的语法都为:
1 2 |
|
查看你的MySQL路径是否存在,存在的情况下复制下来(我的是这么版本,你需要看自己的路径):
/usr/local/mysql-8.0.12-macos10.13-x86_64/bin
我这边之前安装了其他的path变量,所以需要追加:第二行第二个冒号之后就是
export FLUTTER_HOME=/Flutter/flutter
export PATH=$PATH:$FLUTTER_HOME/bin:/usr/local/mysql-8.0.12-macos10.13-x86_64/bin
export android_HOME="/Users/apple/Library/Android/sdk"
export PATH=${PATH}:${ANDROID_HOME}/tools:$ANDROID_HOME/platform-tools
export FLUTTER_STORAGE_BASE_URL="https://mirrors.tuna.tsinghua.edu.cn/flutter"
export PUB_HOSTED_URL="https://mirrors.tuna.tsinghua.edu.cn/dart-pub"
MySQL for Mac 安装教程:https://www.jianshu.com/p/199492627ccc
以上是关于Mac系统 MySQL安装配置环境变量的主要内容,如果未能解决你的问题,请参考以下文章