I have an SQL query that must be run on every startup after a software update (updates come with new installations of mysql and thus change the debian-sys-maint user's password, which my script updates in the database). I have a script that is in /etc/init.d that does this exact thing when I run it as root user: ./update
. But when I boot it does not run correctly. I run the service command to get it to run through the init.d
process, but it says:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO
I put a plaintext password in /root/.my.cnf
to avoid having to use it in various other scripts and to improve security. It can make my mysql call (without -p
) perfectly when I call the script manually, but not when I use the service process and not on boot. There was a mention on another question that the environment might not be set up correctly for the script, but I have no idea what environment variables I'd have to set up to call mysql in a script so that it will read /root/.my.cnf
.
I have already checked to make sure that the script is owned by root and has 755 permissions. What do I have to do to get this to work?