Question

I'm creating a script that can be deployed to multiple administrators who would be able to run it with their own credentials.

I'm getting an Access Denied error from mysql, however. It seems to think that I'm not passing a username to the MySQL command:

Using this script:

set dbUser = "myusername"
set dbPass = "mypassword"
mysql --username=$dbUser --password=$dbPass --database="mydbname" -e "SELECT * FROM sometable"

ERROR 1044 (42000): Access denied for user ''@'localhost' to database

Strangely, if I type the MySQL username and password directly into the MySQL command and run that in a shell script it works fine.

mysql --username="myusername"--password="mypass" --database="mydbname" -e "SELECT * FROM sometable"

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top