What’s the best way to provide a MySql root password (
~/.my.cnf) to cron job without root to have the home folder?
the server I’m using is centos
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
What’s the best way to provide a MySql … password
Using a separate configuration file, as described in the Manual.
What’s the best way to provide a MySql root password
You should not use any high-level credentials for Application connectivity. Not root, not mysql.
Always created a dedicated account for your Application, grant it appropriate permissions, and use that.
Why? You should always keep the Best Tools in the ToolBox for yourself – so that you can clean up the mess made by everybody else!
… without root to have the home folder?
The Linux root account will always have access to the mysql home folder.
By design, root must have access to everything.
mysql_config_editor set -G project_name -u database_name -p -h localhost
- The -p prompts for the password
- -P 3306 for port (default 3306)
- -h could point to a remote server
- Other options are possible
mysql_config_editor set -G o8016 -P 8016 -u root -p -h `hostname`
mysql_config_editor hides the pwd in a ‘dot file’ in your home directory is such a way that access is limited to you and, of course, “root”.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0