Pawel Miszkurka
Pawel Miszkurka

Reputation: 157

Querying remote MySql database with bash

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

some_db="somedb"
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.

Upvotes: 3

Views: 3746

Answers (1)

Ivan Cachicatari
Ivan Cachicatari

Reputation: 4284

You need to add the parameter for remote host -h

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

Upvotes: 3

Related Questions