在 Mac 上通过终端命令连接到 MySQL 数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35675929/
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
Connect to MySQL database via terminal command on Mac
提问by Mark Li
I have been trying to connect to company MySQL database via terminal on my Mac. I downloaded MySQL CLI via 'home brew' on my Mac:
我一直在尝试通过 Mac 上的终端连接到公司的 MySQL 数据库。我在 Mac 上通过“home brew”下载了 MySQL CLI:
$brew install mysql
Then, I followed the format as below:
然后,我遵循以下格式:
$mysql -u user_name -p passwords -h host_name database_name
Yet, I got error message "ERROR 2003 (HY000): Can't connect to MySQL server on 'host_name' (60)". Could any one tell me how to fix this? Thanks!
然而,我收到错误消息“ERROR 2003 (HY000): Can't connect to MySQL server on 'host_name' (60)”。谁能告诉我如何解决这个问题?谢谢!
回答by Yeikel
We definitely need more details to help you , but with a quick guess I think that you need to start MySQL first
我们肯定需要更多详细信息来帮助您,但快速猜测一下,我认为您需要先启动 MySQL。
sudo /usr/local/mysql/support-files/mysql.server start
Also , it is a good idea to check the status of the server before you try to connect to it.
此外,在尝试连接之前检查服务器的状态是个好主意。
sudo /usr/local/mysql/support-files/mysql.server status
*Paths depend on the installation path of MySQL
*路径取决于MySQL的安装路径