简体   繁体   English

在Mac上通过terminal命令连接到MySQL数据库

[英]Connect to MySQL database via terminal command on Mac

I have been trying to connect to company MySQL database via terminal on my Mac. 我一直在尝试通过Mac上的终端连接到公司的MySQL数据库。 I downloaded MySQL CLI via 'home brew' on my Mac: 我在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)". 然而,我收到错误消息“ERROR 2003(HY000):无法连接到'host_name'(60)上的MySQL服务器”。 Could any one tell me how to fix this? 谁能告诉我如何解决这个问题? Thanks! 谢谢!

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的安装路径

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

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