I am trying to run MySQL query on remote machine with this command:
ssh [email protected] "mysql -uroot -proot -e \"use test";""
I am not able to use that database.
Please suggest a working command.
Open a new terminal window. Direct your local MySQL client to 127.0. 0.1:3306 with the MySQL server username and password. Your connection to the remote MySQL server will be encrypted through SSH, allowing you to access your databases without running MySQL on a public IP.
Try this:
mysql -h host -u root -proot -e "show databases;";
Try this:
ssh root@host "mysql database -e 'query to run on table_name; more queries to run;'"
Same can be done with user@host
if that user has permission to execute SQL queries let alone launch mysql in general. Using -e
is the same as --execute
, which will run whatever you put within the trailing quotes (single or double) and quit. The standard output format would be the same as you would see using --batch
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With