Mark Li
Mark Li

Reputation: 459

Connect to MySQL database via terminal command on Mac

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:

$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!

Upvotes: 5

Views: 44364

Answers (1)

Yeikel
Yeikel

Reputation: 935

We definitely need more details to help you , but with a quick guess I think that you need to start MySQL first

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

Upvotes: 4

Related Questions