Pawel Miszkurka Pawel Miszkurka - 4 months ago 6
SQL Question

Querying remote MySql database with bash

I'm trying to query remote database with the following script.

isAnythingToProcess=$(mysql -uroot -proot -D$some_db -e "$checkSearch");

This works for me locally however whenever i try to run bash script to remote AWS server I get error

ERROR 1049 (42000): Unknown database 'somedb'

Any hints?

P.S. The database exists for sure. I can connect to it via MySQL client.


You need to add the parameter for remote host -h

isAnythingToProcess=$(mysql -uroot -proot -h REMOTE_IP -D$some_db -e "$checkSearch");