So I have MySQL hosted inside a docker container. I'm trying to write a bash script to extra some data from MySQL. I've created a file /etc/mysql_pass.cnf inside the docker container, the file contains:
[mysqld]
user=user1
password=pass2
My /etc/my.cnf:
[mysqld]
datadir=XXXX
socket=XXXX
secure-file-priv=XXX
...etc
This is what i've written on the bash script to extract the result from MySQL:
mysqlDate=$(docker exec DOCKER_NAME mysql --defaults-extra-file=/etc/mysql_pass.cnf -D$db -se "SQL_QUERY;")
I get this error ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) It's trying to login as root for some reason, and saying I haven't entered a password?