|
4 | 4 |
|
5 | 5 | # Change the password to be empty.
|
6 | 6 | CHANGED_PASSWORD=false
|
| 7 | +CHANGED_PASSWORD_SHA2=false |
7 | 8 | # Change the password to be empty, recreating the root user on mariadb < 10.2
|
8 | 9 | # where ALTER USER is not available.
|
9 | 10 | # https://stackoverflow.com/questions/56052177/
|
|
45 | 46 | # Install MySQL 8.0 if DB=mysql80
|
46 | 47 | if [[ -n ${DB-} && x$DB =~ ^xmysql80 ]]; then
|
47 | 48 | sudo bash ci/mysql80.sh
|
48 |
| - CHANGED_PASSWORD=true |
| 49 | + CHANGED_PASSWORD_SHA2=true |
49 | 50 | fi
|
50 | 51 |
|
51 | 52 | # Install MySQL 8.4 if DB=mysql84
|
52 | 53 | if [[ -n ${DB-} && x$DB =~ ^xmysql84 ]]; then
|
53 | 54 | sudo bash ci/mysql84.sh
|
54 |
| - CHANGED_PASSWORD=true |
| 55 | + CHANGED_PASSWORD_SHA2=true |
55 | 56 | fi
|
56 | 57 |
|
57 | 58 | # Install MariaDB 10.6 if DB=mariadb10.6
|
@@ -120,6 +121,11 @@ if [ "${CHANGED_PASSWORD}" = true ]; then
|
120 | 121 | # https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/
|
121 | 122 | sudo mysql ${MYSQL_OPTS} -u "${DB_SYS_USER}" \
|
122 | 123 | -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY ''"
|
| 124 | +elif [ "${CHANGED_PASSWORD_SHA2}" = true ]; then |
| 125 | + # In MySQL 5.7, the default authentication plugin is mysql_native_password. |
| 126 | + # As of MySQL 8.0, the default authentication plugin is changed to caching_sha2_password. |
| 127 | + sudo mysql ${MYSQL_OPTS} -u "${DB_SYS_USER}" \ |
| 128 | + -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY ''" |
123 | 129 | elif [ "${CHANGED_PASSWORD_BY_RECREATE}" = true ]; then
|
124 | 130 | sudo mysql ${MYSQL_OPTS} -u "${DB_SYS_USER}" <<SQL
|
125 | 131 | DROP USER 'root'@'localhost';
|
|
0 commit comments