When I log in to mysql from a bash script such as this:
mysql --user="$USERNAME" --password="$PASSWORD" --database="$DATABASE" << EOF
# No command here
EOF;
My user is logged into the database and it works fine. But when my bash script does something as simple as
mysql --user="$USERNAME" --password="$PASSWORD" --database="$DATABASE" << EOF
show tables;
show columns from some_table;
...
# Now there are commands
EOF;
Mysql gives me this error: Access denied for user 'user'@'localhost' to database 'database' What would cause this?
To clarify, I'm perfectly able to just call mysql -uUser -pPass database from the command line, log in, then call show tables;. It's only when run from a bash script, and when that bash script includes a mysql command does my access get denied.
Furthermore is there a simple-to-use library for python/c++ that handles mysql interaction and doesn't involve having to sign up for something in order to obtain the library?