Issue
I am using a cron job to reset my database and each time the cron runs the line-
mysql -u USER -pPASSWORD -h localhost DBNAME < /var/www/SITEFOLDER/mysqldumpfile.sql
Ubuntu warns me not to use the password in the command line. How can I use the reset cron command without using the password in a text format and causing any security issues?
Solution
You can store user & password in a file, and give the path to that file when you use a mysql client.
mysql --defaults-file /path/to/some/file.cnf DBNAME < /var/www/SITEFOLDER/mysqldumpfile.sql
In the .cnf file, you can list user, password, host, and other connection parameters.
[client]
user = scott
password = tiger
host = localhost
See also https://dev.mysql.com/doc/refman/5.7/en/option-file-options.html
Answered By - Bill Karwin