Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

add checks for mysql version, change alter user syntax if it's 8 or g… #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
391 changes: 391 additions & 0 deletions artifact.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@
"propertyName" : {
"type" : "string",
"prettyName": "Property Name",
"pattern": "^$|^[_a-zA-Z0-9]*$",
"pattern": "^$|^[_a-zA-Z0-9\\-]*$",
"default": "",
"maxLength": 40
},
"value": {
"type": "string",
"prettyName": "Value",
"pattern": "^$|^[_a-zA-Z0-9]*$",
"pattern": "^$|^[_a-zA-Z0-9\/\\-\\._]*$",
"default": "",
"maxLength": 40
}
Expand Down
3 changes: 2 additions & 1 deletion src/pluginops/pluginops.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def find_mysql_binaries(connection):
versionArr=versionStr.split(" ")
version=versionArr[3]
if (version !="" and baseName =="mysqld"):
prettyName= versionStr[versionStr.index("(MySQL"):len(versionStr)]
r=re.compile("\((MariaDB|MySQL)")
prettyName= versionStr[r.search(versionStr).start():len(versionStr)]
prettyName= prettyName+" {}".format(version)
repository = RepositoryDefinition(
name=prettyName,
Expand Down
13 changes: 13 additions & 0 deletions src/resources/restore_stage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,19 @@ fi
#
CMD="${INSTALL_BIN}/mysql ${STAGING_CONN} --connect-expired-password -se \"ALTER USER 'root'@'localhost' IDENTIFIED BY ${STAGINGPASS};UPDATE mysql.user SET authentication_string=PASSWORD(${STAGINGPASS}) where USER='root';FLUSH PRIVILEGES;\""
CMDFORLOG="${INSTALL_BIN}/mysql ${STAGING_CONN} --connect-expired-password -se \"ALTER USER 'root'@'localhost' IDENTIFIED BY '********';UPDATE mysql.user SET authentication_string=PASSWORD('********') where USER='root';FLUSH PRIVILEGES;\""

# if mysql version >= 8, then change password syntx is different
versionRegex="Ver ([0-9]*)"
versionString=$(${MYSQLD}/mysqld -V)
if [[ $versionString =~ $versionRegex ]]; then
versionNumber="${BASH_REMATCH[1]}";
if [[ $versionNumber -ge 8 ]]; then
masklog "MySQL Version 8 or greater, change password syntax altered."
CMD="${INSTALL_BIN}/mysql ${STAGING_CONN} --connect-expired-password -se \"ALTER USER 'root'@'localhost' IDENTIFIED BY ${STAGINGPASS};FLUSH PRIVILEGES;\""
CMDFORLOG="${INSTALL_BIN}/mysql ${STAGING_CONN} --connect-expired-password -se \"ALTER USER 'root'@'localhost' IDENTIFIED BY '********';FLUSH PRIVILEGES;\""
fi
fi

masklog "Final Command to Change Password is : ${CMDFORLOG}"
command_runner "${CMD}" 5

Expand Down
14 changes: 14 additions & 0 deletions src/resources/restore_stage_bi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,20 @@ fi
########################################################################
# Change Password for Staging Conn ...
CMD="${INSTALL_BIN}/mysql ${STAGING_CONN} --connect-expired-password -se \"ALTER USER 'root'@'localhost' IDENTIFIED BY ${STAGINGPASS};UPDATE mysql.user SET authentication_string=PASSWORD(${STAGINGPASS}) where USER='root';FLUSH PRIVILEGES;\""
CMDFORLOG="${INSTALL_BIN}/mysql ${STAGING_CONN} --connect-expired-password -se \"ALTER USER 'root'@'localhost' IDENTIFIED BY '********';UPDATE mysql.user SET authentication_string=PASSWORD('********') where USER='root';FLUSH PRIVILEGES;\""

# if mysql version >= 8, then change password syntx is different
versionRegex="Ver ([0-9]*)"
versionString=$(${MYSQLD}/mysqld -V)
if [[ $versionString =~ $versionRegex ]]; then
versionNumber="${BASH_REMATCH[1]}";
if [[ $versionNumber -ge 8 ]]; then
masklog "MySQL Version 8 or greater, change password syntax altered."
CMD="${INSTALL_BIN}/mysql ${STAGING_CONN} --connect-expired-password -se \"ALTER USER 'root'@'localhost' IDENTIFIED BY ${STAGINGPASS};FLUSH PRIVILEGES;\""
CMDFORLOG="${INSTALL_BIN}/mysql ${STAGING_CONN} --connect-expired-password -se \"ALTER USER 'root'@'localhost' IDENTIFIED BY '********';FLUSH PRIVILEGES;\""
fi
fi

masklog "Final Command to Change Password is : ${CMD}"
command_runner "${CMD}" 5

Expand Down