简体   繁体   English

MySQL 命令在 M1 Mac 中找不到

[英]MySQL command is not found in M1 Mac

as titled, my question is in my m1 Mac terminal, after successfully installing MySQL from the official page, I enter the mysql command, but it returns command not found.如标题,我的问题是在我的 m1 Mac 终端中,从官方页面成功安装 MySQL 后,我输入 mysql 命令,但它返回找不到命令。

I googled alot, and this is one of the solution i found: mysql command is not found in macOS我用谷歌搜索了很多,这是我找到的解决方案之一: mysql command is not found in macOS

Per the instruction of the page, I found my path to my mysql already, it's /usr/local/mysql-8.0.27-macos11-arm64/bin , I am now in my zshrc too, but i don't know how to put export PATH=$PATH:/usr/local/<my-path>/bin in to zshrc.根据页面的说明,我已经找到了我的 mysql 路径,它是/usr/local/mysql-8.0.27-macos11-arm64/bin ,我现在也在我的 zshrc 中,但我不知道如何将export PATH=$PATH:/usr/local/<my-path>/bin放入 zshrc。

While there are so many lines of different settings in it, how do i specify this path is for mysql?虽然其中有很多行不同的设置,但我如何指定此路径用于 mysql? and where to put?放在哪里?

Thank you guys感谢你们

If not you using homebrew and have a manual installation of mysql:如果您不使用自制软件并手动安装 mysql:

vi ~/.zshrc
export PATH=${PATH}:/usr/local/mysql-8.0.28-macos11-x86_64/bin/
source ~/.zshrc

note: replace /mysql-8.0.28-maos11-x86_64/ with whichever version of mysql is installed.注意:将 /mysql-8.0.28-maos11-x86_64/ 替换为已安装的 mysql 版本。

Since PATH is already exported (try a printenv PATH to see), you don't need to export it, but only extend it.由于PATH已经导出(尝试使用printenv PATH查看),因此您不需要导出它,而只需扩展它。

Hence, you can do in your .zshrc a因此,你可以在你的 .zshrc 中做

path+=/usr/local/mysql-8.0.27-macos11-arm64/bin

BTW, I would also do a顺便说一句,我也会做一个

typeset -aU path

(if it is not there already), to ensure that you don't have duplicate entries in your PATH/path. (如果它还没有),以确保您的 PATH/路径中没有重复的条目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM