I want to change mysql password periodically and want to register the changes password in a Property file.
Can any one suggest as how to achieve the same?
1 Answer
Yes, Try to generate a random password with java code and set it as mysql user password by scheduling a cron job or scheduled task by OS and write the same password in property file or mail yourself.. Update the password by java code using this sample code..
String sql = "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456')";
Statement smt = con.createStatement();
smt.executeQuery(sql);