如何在 mac 上安装命令行 MySQL 客户端?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30990488/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I install command line MySQL client on mac?
提问by hch
I want to install the MySQL client for the command line, not a GUI. I have searched over the web but only found instructions on installing the MySQL server.
我想为命令行安装 MySQL 客户端,而不是 GUI。我在网上搜索过,但只找到了有关安装 MySQL 服务器的说明。
回答by user1659189
install MySQLWorkbench, then
安装 MySQLWorkbench,然后
export PATH=$PATH:/Applications/MySQLWorkbench.app/Contents/MacOS
回答by HymanSparrow
If you have already installed MySQL from the disk image (dmg) from http://dev.mysql.com/downloads/), open a terminal, run:
如果您已经从http://dev.mysql.com/downloads/的磁盘映像 (dmg) 安装了 MySQL ,请打开终端,运行:
echo 'export PATH=/usr/local/mysql/bin:$PATH' >> ~/.bash_profile
then, reload .bash_profile
by running following command:
然后,.bash_profile
通过运行以下命令重新加载:
. ~/.bash_profile
You can now use mysql
to connect to any mysql server:
您现在可以使用mysql
连接到任何 mysql 服务器:
mysql -h xxx.xxx.xxx.xxx -u username -p
Credit & Reference: http://www.gigoblog.com/2011/03/13/add-mysql-to-terminal-shell-in-mac-os-x/
信用与参考:http: //www.gigoblog.com/2011/03/13/add-mysql-to-terminal-shell-in-mac-os-x/
回答by Geek
Best option is:
最佳选择是:
brew install mysql
回答by troseman
Mysql has a client-only set of utilities:
Mysql 有一组仅限客户端的实用程序:
Mysql client shell https://dev.mysql.com/downloads/shell/
Mysql 客户端外壳 https://dev.mysql.com/downloads/shell/
Other command line utilities https://dev.mysql.com/downloads/utilities/
其他命令行实用程序 https://dev.mysql.com/downloads/utilities/
Mac OSX version available.
Mac OSX 版本可用。
回答by Alex W
This strictly installs a command line client, without the other overhead:
这严格安装命令行客户端,没有其他开销:
Install Homebrew (if you don't have it):
安装 Homebrew(如果你没有):
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then, install mysql-client
:
然后,安装mysql-client
:
brew install mysql-client
Then, add the mysql-client
binary directory to your PATH:
然后,将mysql-client
二进制目录添加到您的 PATH:
echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile
Finally, reload your bash profile:
最后,重新加载您的 bash 配置文件:
source ~/.bash_profile
Then you should be able to run mysql
in a terminal, if not try opening a new terminal
那么你应该能够mysql
在终端中运行,如果没有尝试打开一个新终端
回答by egze
There is now a mysql-client
formula.
现在有一个mysql-client
公式。
brew install mysql-client
brew install mysql-client
回答by caccialdo
Open the "MySQL Workbench" DMG file and
打开“MySQL Workbench”DMG 文件并
# Adjust the path to the version of MySQL Workbench you downloaded
cp "/Volumes/MySQL Workbench 6.3.9.CE/MySQLWorkbench.app/Contents/MacOS/mysql" /usr/local/bin
# Make sure it's executable
chmod +x /usr/local/bin/mysql
Eject the DMG disk
弹出 DMG 磁盘
回答by Michael Lihs
For installing mysql-shell
with homebrew, run
要mysql-shell
使用自制软件安装,请运行
brew cask install mysql-shell
you can then launch the mysql shell with
然后你可以启动mysql shell
mysqlsh
if you want to enter SQL mode directly, run
如果想直接进入SQL模式,运行
mysqlsh --sql
回答by Paul Kenjora
If you installed from the DMG on a mac, it created a mysql client but did not put it in your user path.
如果您在 mac 上从 DMG 安装,它会创建一个 mysql 客户端,但没有将它放在您的用户路径中。
Add this to your .bash_profile
:
将此添加到您的.bash_profile
:
export PATH="/usr/local/mysql/bin:$PATH
This will let you run mysql
from anywhere as you.
这将使您mysql
可以像您一样从任何地方奔跑。
回答by Kimmo Hintikka
As stated by the earlier answer you can get both mysql server and client libs by running
正如前面的答案所述,您可以通过运行获得 mysql 服务器和客户端库
brew install mysql
.
brew install mysql
.
There is also client only installation. To install only client libraries run
还有仅客户端安装。要仅安装客户端库,请运行
brew install mysql-connector-c
brew install mysql-connector-c
In order to run these commands, you need homebrew package manager in your mac. You can install it by running
为了运行这些命令,您需要在 Mac 中安装自制软件包管理器。您可以通过运行安装它
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"