5

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!

2
  • You are supplying host_name ... replace with actual host machine name Commented Feb 27, 2016 at 23:22
  • Yes, I was using the actual host name, user name and passwords. Here, for indication, I just put an placeholder. Commented Feb 28, 2016 at 4:34

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

13 Comments

Hi Yeikel! Thanks so much for the help! I was trying to execute sql query via terminal on my Mac OSX to connect to our company MySQL database. I was managed to set up SSH tunnel via 'SSH Tunnel Manager' app and successfully connected to MySQL database on 'Sequal Pro' app. However, when I tried to connect MySQL on terminal with the above steps, it returned my that error message. I have also tried to start mysql server with your command but it says "ERROR! The server quit without updating PID file (/usr/local/mysql/data/tw-mba-mli.pid).". Is it due the missing of PID file? Please let me know.
Also, I have checked the .err file and found out the message: [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. [ERROR] InnoDB: Unable to lock ./ibdata1 error: 35.
@MarkLi The error is telling you that you have MySQL running in your computer and that's why you can't start a second instance. I find it suspicious that you are able to connect with Sequal Pro and not with the command line. Can you paste the exact command you're executing ?
Sure! In the terminal, I executed the command "mysql -u mmr -p XATtAoqaU6JahuMib2BH -h db-kredd-ro-app-002.atla.company.com roi_add_prod" to try to connect the database. Yet, now I am receiving the mysql cli user menu as result. Does it indicate that I am passing the wrong parameters to the command? Before executing the command, I made sure that the SSH tunnel was connected and 'Sequal Pro' was off. Also, I have tried to run command - "sudo /usr/local/mysql/support-files/mysql.server status" and it said "MySQL is not running".
@MarkLi Did you try to stop the server first and then try to start it? Do a full reboot of the machine before trying to do so. Also , what about passing 'localhost' as the host?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.