Mysql – How to connect to remote MySQL server with sshuser and thesqluser being distinct

connectivityMySQLremote

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.

Best Answer

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.