I have a server with Rackspace. I want to access the database from my local machine command line.
I tried like:
mysql -u username -h my.application.com
For Mac, use the following command:
mysql -u app -h hostaddress -P port -D dbname -p
and then enter the password when prompted.
mysql servers are usually configured to listen only to localhost (127.0.0.1), where they are used by web applications.
If that is your case but you have SSH access to your server, you can create an ssh tunnel and connect through that.
On your local machine, create the tunnel.
ssh -L 3307:127.0.0.1:3306 -N $user@$remote_host
(this example uses local port 3307, in case you also have mysql running on your local machine and using the standard port 3306)
Now you should be ale to connect with
mysql -u $user -p -h 127.0.0.1 -P 3307
If you are on windows, try Visual Studio Code with MySQL plugins, an easy and integrated way to access MySQL data on a windows machine. And the database tables listed and can execute any custom queries.
simply put this on terminal at ubuntu:
mysql -u username -h host -p
Now hit enter
terminal will ask you password, enter the password and you are into database server
I assume you have MySQL installed on your machine. Execute the command below after filling missing details:
mysql -uUSERNAME -pPASSWORD -hHOSTNAME -P3306
This one worked for me in mysql 8, replace hostname
with your hostname and port_number
with your port_number, you can also change your mysql_user if he is not root
mysql --host=host_name --port=port_number -u root -p
Further Information Here