I am new to MySQL and Linux (BASH). I am attempting to run a SQL query from BASH. I often do similar things using Oracle and KShell, but am new to the MySQL/Linux/BASH environment.
When I enter the following on the shell command line everything works fine:
mysql -h dmysql1 -u zz99 -p
select * from table;
However I need to execute this from a script. So I have created a script called SelectTestdata.sh which contains the following:
mysql -h dmysql1 -u zz99 -p zz99123
mysql use serversdb
mysql < selectdata (selectdata is a file with select * from testdata; in it.)
I then do the following:
zz99@dmysql1:~/batch/MySQL> bash SelectTestdata.sh
And it returns:
After entering my password it returns:
ERROR 1049 (42000): Unknown database 'zz99123'
So I have 2 questions:
1) Why is it asking for my password when I passed it the password in the SelectTestdata.sh script?
2) after keying in zz99123, why does it think zz99123 is the database name?
Any guidance will be appreciated (and rewarded!!!)