Hmmm.
Is DATABASE an obfuscation for your post, or is that a variable that exists in your CLI environment?
If the latter, it's not present in the environment when run from the init file...either populate within the script, or use the actual database name there.
Oh. Please put code and output examples in [code] tags...
Code:
#!/bin/bash
query_result=$(/usr/bin/mysql -NB -u dbuser -p'dbpwd' -DDATABASE -e "SELECT name FROM users ORDER BY id;")
echo "Result: "$query_result >/tmp/ppp.txt
PS You're sure that mysql is at /usr/bin/mysql? Mine is at /bin/mysql