mysql_secure_installation cannot set the root password on Ubuntu
ERROR 1819 (HY000): Your password does not satisfy the current policy requirementsShort 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.
Fix it fast
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';"2Match what you see, then jump to its fix
- 1
The 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
ERROR 1819 (HY000): Your password does not satisfy the current policy requirementsThe new password is rejected by the password validation policyFix
- 1
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_installation3Verify
A password login for root now works.
mysql -u root -p -e "SELECT CURRENT_USER();"Confirmed by ubuntu.com
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
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- ShopGoAn e-commerce aggregator with a Python scraping engine behind its catalog, past 10K Google Play downloads.
Related fixes
Databases
MySQL ERROR 1524: the auth_socket plugin is not loaded
ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded
The account is set to authenticate with auth_socket, but the server has not loaded that plugin.
2 causes, each with a fixDatabases
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 fixDatabases
Installing the Airflow MySQL provider fails on pkg-config or mysqlclient
Building the mysqlclient wheel fails during the install
The Airflow MySQL provider depends on mysqlclient, which pip compiles against the MySQL C client library.
2 causes, each with a fixDatabases
Compiling a C or C++ program that includes mysql.h fails
undefined reference to `mysql_init'
The compiler only finds mysql.h when the MySQL client development files are installed and their folder is on the include path.
3 causes, each with a fixDatabases
An EC2 instance cannot reach its RDS database
Could not open connection to the host, on port <port>: Connect failed
RDS denies all access until a security group allows it.
3 causes, each with a fixDatabases
Locked out of a fresh MariaDB install as root on Mac or Linux
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
A fresh MariaDB root account is not a normal password account.
3 causes, each with a fix