I'm trying to connect to a remote MySQL server via ssh so that I have write-access to export some data. At the moment I can do the following:

  1. Connect to the remote MySQL using mysql -u mysqluser -pPASSWORD -h HOSTIP DATABASENAME
  2. Connect to the machine using ssh sshuser@HOSTIP

(Note that HOSTIP is the same for ssh and mysql server, but mysqluser and sshuser are different).

However, I cannot connect to remote MySQL via ssh. I tried two things:

  1. After ssh-ing into the machine, I tried mysql in the terminal but it is not installed.
  2. I tried ssh -L 1234:mysqlhost:3306 sshuser@sshhost. However, I can only enter my sshpassword, after which I get ssh-ed in but no connection to MySQL still.
  • Haven't touched mysql in a while, but what do you mean by it's not installed after you SSH in? Have you updated the path environment variable such that you can see the mysql command? Can you change directory to mysql's bin and run it that way? If not you need to install the client first to access it. Jul 17, 2014 at 16:19
  • After ssh-ing in, I tried mysql in the terminal but it is not installed. It's Mac with brew installed, so I tried brew install mysql but I got error Error: Cannot write to /usr/local/Cellar I don't have root access.
    – Heisenberg
    Jul 17, 2014 at 16:28
  • I'm confused, is the machine you're trying to SSH into the mysql server? Then it should be installed. Jul 17, 2014 at 17:48

1 Answer 1


First you need to do SSH user@serveripaddress then click enter you will be prompting to enter password. please enter the same.

After that use mysql -u root -p then click enter you need to enter mysql password. If mysql is not installed in your server. Please install then get root password from DBA and then try.

  • Mysql is indeed not installed on the remote machine, but how is that possible? Doesn't this machine have the mysql server on itself?
    – Heisenberg
    Jul 17, 2014 at 5:29
  • you need to install mysql manually in the remote machine so that you can able to access that..
    – Karthick
    Jul 17, 2014 at 5:33
  • what if I don't have sudo access? I'm only a user on that remote machine.
    – Heisenberg
    Jul 18, 2014 at 16:02
  • You need to get root credential for accessing Mysql..
    – Karthick
    Jul 19, 2014 at 4:10

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.