Mysql update password
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 @@
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 @@
}
}
+ /**
+ * 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());
}