MySQL 8.4 has a catch 22 situation where you can’t set a new password with mysqladmin anymore, because
1 |
'Plugin 'mysql_native_password' is not loaded' |
So if you had an automated setup script that does something like this:
1 2 3 4 5 |
# PASSWORD=$(grep 'A temporary password' /var/log/mysqld.log |awk -F: '{print $NF}' | xargs) # NEW_PASSWORD=`pwgen -s -1 -y 32` # mysqladmin -u root- p"$PASSWORD" password "$NEW_PASSWORD" mysqladmin: connect to server at 'localhost' failed error: 'Plugin 'mysql_native_password' is not loaded' |
and wanting to lower the password verification level all results in
1 |
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. |
Why always so complicated, Oracle? Why always so hostile towards the user?
Anyhow.
Solution
1 2 3 4 |
PASSWORD=$(grep 'A temporary password' /var/log/mysqld.log |awk -F: '{print $NF}' | xargs) NEW_PASSWORD="{{{password}}}" echo "ALTER USER 'root'@'localhost' IDENTIFIED BY '$NEW_PASSWORD';"|mysql -u root -p"$PASSWORD" echo "SET GLOBAL validate_password.policy=MEDIUM"|mysql -u root -p"$NEW_PASSWORD" |