Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Databases and Redis

mysql_secure_installation cannot set the root password on Ubuntu

ErrorERROR 1819 (HY000): Your password does not satisfy the current policy requirements

Short answer

On Ubuntu the packaged MySQL root account uses auth_socket: you enter MySQL with sudo mysql, and no password is stored, so the tool has no password to check. Give root a password first with ALTER USER ... IDENTIFIED WITH caching_sha2_password BY '...' inside sudo mysql, then run mysql_secure_installation and enter it.

  • Applies to MySQL 8.4, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    See how the root account authenticates. If the plugin is auth_socket, there is no password to give the tool.

    sudo mysql -u root -e "SELECT user, host, plugin FROM mysql.user WHERE user = 'root';"
  2. 2Match what you see, then jump to its fix

    1. 1The plugin column shows auth_socket for root@localhost, so root has no stored password.root uses auth_socket, so there is no password for the tool to checkFix
    2. 2ERROR 1819 (HY000): Your password does not satisfy the current policy requirementsThe new password is rejected by the password validation policyFix

What does the error look like?

  • ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

Cause 1 of 2

root uses auth_socket, so there is no password for the tool to check

1Check

auth_socket matches the operating-system user name to the MySQL user name over the local socket. The Ubuntu docs say no password is needed and you reach MySQL with sudo mysql -u root. The tool itself always prompts for a password, even if you pass --password.

sudo mysql -u root -e "SELECT CURRENT_USER();"

2Fix

Enter MySQL through the socket with sudo, switch root to a password plugin with ALTER USER (the manual calls it the preferred statement over SET PASSWORD), then run the tool and give it that password.

sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'a-Strong#Passw0rd';
-- leave the client, then:
mysql_secure_installation

3Verify

A password login for root now works.

mysql -u root -p -e "SELECT CURRENT_USER();"

Confirmed by ubuntu.com

Did this fix it?

Cause 2 of 2

The new password is rejected by the password validation policy

1Check

When the validate_password component is on, the default MEDIUM policy wants at least 8 characters with a digit, a lowercase letter, an uppercase letter and a special character. It also rejects a password that matches the user name.

SHOW VARIABLES LIKE 'validate_password%';
SELECT VALIDATE_PASSWORD_STRENGTH('a-Strong#Passw0rd');

2Fix

Choose a password that meets the policy, or lower the policy level only if you accept weaker passwords.

ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'Longer#Passw0rd9';

3Verify

The ALTER USER statement returns OK.

SELECT VALIDATE_PASSWORD_STRENGTH('Longer#Passw0rd9');

Confirmed by dev.mysql.com

Did this fix it?

How do I stop it coming back?

  • Keep auth_socket for root on a server where only administrators have shell access, and create separate accounts with passwords for applications.
  • Pick the validate_password policy level when the tool asks, and write the password rule down for the team.
  • Use ALTER USER, not SET PASSWORD, when you change how an account authenticates.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Databases

MySQL rejects a new password with error 1819

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

Error 1819 means the validate_password component is installed and your cleartext password broke its policy.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.