Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to MySQL database via terminal command on Mac

Tags:

shell

mysql

macos

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!

like image 991
Mark Li Avatar asked Sep 26 '22 06:09

Mark Li


1 Answers

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

like image 125
Yeikel Avatar answered Nov 15 '22 11:11

Yeikel