I have a bash script that opens queries from MySQL. For example:
$ cat script.sh
mysql -u joe -D database -p ........ < first_query.sql
mysql -u joe -D database -p ........ < second_query.sql
This 2 lines inside my script.sh file return the results of the queries, but: Everytime I call the ‘mysql’ command, if it has the «-p» option, it asks for password TWICE (because I call mysql twice). How can I avoid this behavior?
I have tried passing my password as parameter, for example:
$ sh script.sh ‘mypassword’
and storing it in a variable and putting it after the «-p» option. But it still asks for the password twice.