Repository: brooklyn-library Updated Branches: refs/heads/master 05b69832b -> 2f99257d3
Mysql update password Project: http://git-wip-us.apache.org/repos/asf/brooklyn-library/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-library/commit/2347c0a5 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-library/tree/2347c0a5 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-library/diff/2347c0a5 Branch: refs/heads/master Commit: 2347c0a510d733a97f7ffd84d5d2e575dd91b2c1 Parents: 05b6983 Author: Duncan Godwin <[email protected]> Authored: Wed Nov 8 15:01:52 2017 +0000 Committer: Duncan Godwin <[email protected]> Committed: Thu Nov 9 14:45:40 2017 +0000 ---------------------------------------------------------------------- .../entity/database/mysql/MySqlSshDriver.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/2347c0a5/software/database/src/main/java/org/apache/brooklyn/entity/database/mysql/MySqlSshDriver.java ---------------------------------------------------------------------- diff --git a/software/database/src/main/java/org/apache/brooklyn/entity/database/mysql/MySqlSshDriver.java b/software/database/src/main/java/org/apache/brooklyn/entity/database/mysql/MySqlSshDriver.java index 97fcb47..9a8ae3c 100644 --- a/software/database/src/main/java/org/apache/brooklyn/entity/database/mysql/MySqlSshDriver.java +++ b/software/database/src/main/java/org/apache/brooklyn/entity/database/mysql/MySqlSshDriver.java @@ -186,6 +186,12 @@ public class MySqlSshDriver extends AbstractSoftwareProcessSshDriver implements boolean hasCreationScript = copyDatabaseCreationScript(); timer.waitForExpiryUnchecked(); + /* + * TODO: this should not assume that the password is blank. + * There may be an existing setup specified by datadir which has an existing password. The changePassword function + * has been altered to try the specified `mysql.password` or blank to allow for a fresh install or a specified datadir. + * This fix addresses the problem short term, but it should be properly fixed in any re-implementation. + */ changePassword("", getPassword()); if (hasCreationScript) @@ -204,13 +210,22 @@ public class MySqlSshDriver extends AbstractSoftwareProcessSshDriver implements } } + /** + * Updates the password, tries both the old and new password in-case the password has already been changed + * @param oldPass + * @param newPass + */ @Override public void changePassword(String oldPass, String newPass) { DynamicTasks.queue( SshEffectorTasks.ssh( "cd "+getRunDir(), - getBaseDir()+"/bin/mysqladmin --defaults-file="+getConfigFile()+" --password=" + oldPass + " password "+newPass) - .summary("setting password") + BashCommands.alternatives( + getBaseDir()+"/bin/mysqladmin --defaults-file="+getConfigFile()+" --password=" + oldPass + " password "+newPass, + getBaseDir()+"/bin/mysqladmin --defaults-file="+getConfigFile()+" --password=" + newPass + " password "+newPass + ) + ) + .summary("Checking and updating password") .requiringExitCodeZero()); }
