To install the command line MySQL client you should do:
sudo apt-get install mysql-client
and then you can do
mysql -h HOST -P PORT_NUMBER -u USERNAME -p
However you may need to alter the set up of the MySQL server. By default on ubuntu the MySQL server will only accept connections from the local server. The setting is called
bind-address and is set in
/etc/mysql/my.cnf. By default it is
127.0.0.1 - you should change it to the IP address of the server. If the server has multiple IP addresses you can choose just one IP address (say for the internal network) or have MySQL listen to all IP addresses by making the value
You will also need to ensure that the MySQL user can access the database. Following instructions on the internet, you may have created user
'myname'@'localhost' - that user will not be able to connect remotely. To create a new user who can connect from your client IP address you need to do something like:
GRANT ALL PRIVILEGES ON database_name TO 'username'@'192.168.0.51' IDENTIFIED BY 'password';
Read a little more about the address specification MySQL uses.
Finally don't forget to ensure that the server firewall will allow access to the MySQL port - the default is 3306.