Would like to implement a daily cron task that repairs & optimizes all databases on our MySQL server. Far as I can tell, though, the root password would need to be visible in order to do this. Here is the cron that works, but cannot be implemented for obvious reasons:
mysqlcheck -u root -p[ROOTPASSWD] --auto-repair --optimize --all-databases > /dev/null 2>&1
Any thoughts on how this daily task can be performed without leaving a gaping security hole? If the crontab is opened with sudo permissions, would this eliminate the need to include the MySQL password in the repair & optimize command?