Pawel Miszkurka Pawel Miszkurka - 1 year ago 80
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.

Answer Source

You need to add the parameter for remote host -h

isAnythingToProcess=$(mysql -uroot -proot -h REMOTE_IP -D$some_db -e "$checkSearch");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download