3

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.

4
  • How are you connecting to remote server? Commented Jun 24, 2016 at 16:48
  • The code is part of my larger bash script. As a client application I use Sequel Pro Commented Jun 24, 2016 at 16:52
  • The fact that the client can connect has nothing to do with the question if that database exists. One MySQL server holds many databases. If that server tells you the database does not exist, then most likely it does not or you do not have the permission to use it. Commented Jun 24, 2016 at 16:54
  • You have to add -h and specify the host name it should be $(mysql -uroot -proot -D$some_db -h<host> -e "$checkSearch"); Commented Jun 24, 2016 at 16:55

1 Answer 1

3

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");
Sign up to request clarification or add additional context in comments.

2 Comments

Obvious mistake. Thank you. Feel stupid posting question about it.
Mistake happens, no problem :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.