Jer*_*rry 8 mysql macos homebrew
我使用brew安装了mysql@5.6。以下是我跑过的命令
brew install mysql@5.6
sudo chmod -R 777 /usr/local/var/mysql
sudo ln -s /usr/local/Cellar/mysql\@5.6/5.6.41/bin/mysql /usr/local/bin/mysql
sudo cp /usr/local/Cellar/mysql\@5.6/5.6.41/homebrew.mxcl.mysql.plist /Library/LaunchAgents/
sudo chown root /Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo chmod 600 /Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo chmod +x /Library/LaunchAgents/homebrew.mxcl.mysql.plist
launchctl load -w /Library/LaunchAgents/homebrew.mxcl.mysql.plist
mysql.server start
Run Code Online (Sandbox Code Playgroud)
sh:mysql.server:找不到命令
这是我得到的输出。mysql --version提供输出
使用EditLine包装器的osx10.13(x86_64)的mysql Ver 14.14 Distrib 5.6.41
如果我通过酿造开始服务
brew services start mysql@5.6
Run Code Online (Sandbox Code Playgroud)
但是当我运行mysql -uroot时
错误2002(HY000):无法通过套接字'/tmp/mysql.sock'连接到本地MySQL服务器(2)
Cyc*_*ode 26
我认为您也需要启动该服务:
brew services start mysql@5.6
Run Code Online (Sandbox Code Playgroud)
然后,您可以使用以下命令检查mysql服务是否正在运行:
brew services list
Run Code Online (Sandbox Code Playgroud)
现在尝试为mysql包创建符号链接:
brew link --force mysql@5.6
Run Code Online (Sandbox Code Playgroud)
您可能需要将mysql的位置添加到路径中,以找到包的位置:
brew list mysql@5.6
Run Code Online (Sandbox Code Playgroud)
然后将位置添加到bin文件夹的末尾~/.profile或~/.bash_profile文件。例如:
export PATH=$PATH:/usr/local/Cellar/mysql@5.6/5.6.41/bin
Run Code Online (Sandbox Code Playgroud)
然后重新加载文件:
source ~/.bash_profile
Run Code Online (Sandbox Code Playgroud)
现在,您应该可以使用mysql并连接到本地正在运行的服务器。