Where is the best place to store the mysql root password?
I had been putting it only in the root user's /root/.my.cnf
file, which works fine for doing normal updates, backups, etc.
However, the (debian)/ubuntu logrotate script (for instance) doesn't look at that file.
I've currently worked around this by adding:
!include /root/.my.cnf
to the /etc/mysql/debian.cnf
file, but this seems kind of … wrong. For a start, there's big
# Automatically generated for Debian Scripts. DO NOT TOUCH
at the top of the file.
There is no debian-sys-maint
user in /etc/passwd
, which I thought had something to do with it – but is that historical now?
Any current best practices/documentation I'm missing?
Best Answer
The Debian package creates a MySQL user
debian-sys-maint@localhost
separate from the MySQLroot@localhost
user, and uses that user and password (stored in/etc/mysql/debian.cnf
) in the scripts for log rotation, database upgrades, startup and shutdown scripts and so on.