mysqldude

Resetting lost root password

Version compatibility

StepMySQLMariaDB
5.65.78.08.4910.610.1111.411.8
--skip-grant-tables + UPDATE mysql.user SET password=PASSWORD() (pre-5.7 recipe)
original post
✓✗ 1054✗ 1064✗ 1064✗ 1064✗ 1348✗ 1348✗ 1348✗ 1348
--skip-grant-tables + UPDATE mysql.user SET authentication_string=PASSWORD() (5.7 recipe)
original post
≠✓✗ 1064✗ 1064✗ 1064✗ 1348✗ 1348✗ 1348✗ 1348
--skip-grant-tables + FLUSH PRIVILEGES; ALTER USER ... IDENTIFIED BY (modern)
modern rewrite
✗ 1064✓✓✓✓✓✓✓✓
--skip-grant-tables + FLUSH PRIVILEGES; SET PASSWORD FOR ... = 'plain'
version check
✗ 1372✓✓✓✓✗ 1372✗ 1372✗ 1372✗ 1372
--skip-grant-tables + FLUSH PRIVILEGES; SET PASSWORD FOR ... = PASSWORD('x')
version check
✓✓✗ 1064✗ 1064✗ 1064✓✓✓✓
--init-file containing ALTER USER ... IDENTIFIED BY (no skip-grant-tables)
modern rewrite
≠✓✓✓✓✓✓✓✓
--skip-grant-tables + UPDATE mysql.user SET password=PASSWORD() (pre-5.7 recipe) original post
MySQL 5.6✓5.7✗ 10548.0✗ 10648.4✗ 10649✗ 1064
MariaDB 10.6✗ 134810.11✗ 134811.4✗ 134811.8✗ 1348
--skip-grant-tables + UPDATE mysql.user SET authentication_string=PASSWORD() (5.7 recipe) original post
MySQL 5.6≠5.7✓8.0✗ 10648.4✗ 10649✗ 1064
MariaDB 10.6✗ 134810.11✗ 134811.4✗ 134811.8✗ 1348
--skip-grant-tables + FLUSH PRIVILEGES; ALTER USER ... IDENTIFIED BY (modern) modern rewrite
MySQL 5.6✗ 10645.7✓8.0✓8.4✓9✓
MariaDB 10.6✓10.11✓11.4✓11.8✓
--skip-grant-tables + FLUSH PRIVILEGES; SET PASSWORD FOR ... = 'plain' version check
MySQL 5.6✗ 13725.7✓8.0✓8.4✓9✓
MariaDB 10.6✗ 137210.11✗ 137211.4✗ 137211.8✗ 1372
--skip-grant-tables + FLUSH PRIVILEGES; SET PASSWORD FOR ... = PASSWORD('x') version check
MySQL 5.6✓5.7✓8.0✗ 10648.4✗ 10649✗ 1064
MariaDB 10.6✓10.11✓11.4✓11.8✓
--init-file containing ALTER USER ... IDENTIFIED BY (no skip-grant-tables) modern rewrite
MySQL 5.6≠5.7✓8.0✓8.4✓9✓
MariaDB 10.6✓10.11✓11.4✓11.8✓
✓works ✓ 1062fails with the error the step demonstrates ⚠works with a warning ≠runs, result differs ✗fails Tested 2026-11-25 on 5.6.51, 5.7.44, 8.0.46, 8.4.13, 9.7.4, 10.6.28, 10.11.19, 11.4.13, 11.8.9
What the warnings and failures say (10)
  • --skip-grant-tables + UPDATE mysql.user SET password=PASSWORD() (pre-5.7 recipe) (MySQL 5.7): error 1054: ERROR 1054 (42S22) at line 1: Unknown column 'password' in 'field list'
  • --skip-grant-tables + UPDATE mysql.user SET password=PASSWORD() (pre-5.7 recipe) (MySQL 8.0, MySQL 8.4, MySQL 9): error 1064: ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('Reset0pw!') W
  • --skip-grant-tables + UPDATE mysql.user SET password=PASSWORD() (pre-5.7 recipe) (MariaDB 10.6, MariaDB 10.11, MariaDB 11.4, MariaDB 11.8): error 1348: ERROR 1348 (HY000) at line 1: Column 'Password' is not updatable
  • --skip-grant-tables + UPDATE mysql.user SET authentication_string=PASSWORD() (5.7 recipe) (MySQL 5.6): SQL ran without error but the new password does not work (old password still works)
  • --skip-grant-tables + UPDATE mysql.user SET authentication_string=PASSWORD() (5.7 recipe) (MySQL 8.0, MySQL 8.4, MySQL 9): error 1064: ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('Reset1pw!') W
  • --skip-grant-tables + UPDATE mysql.user SET authentication_string=PASSWORD() (5.7 recipe) (MariaDB 10.6, MariaDB 10.11, MariaDB 11.4, MariaDB 11.8): error 1348: ERROR 1348 (HY000) at line 1: Column 'authentication_string' is not updatable
  • --skip-grant-tables + FLUSH PRIVILEGES; ALTER USER ... IDENTIFIED BY (modern) (MySQL 5.6): error 1064: ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY '
  • --skip-grant-tables + FLUSH PRIVILEGES; SET PASSWORD FOR ... = 'plain' (MySQL 5.6, MariaDB 10.6, MariaDB 10.11, MariaDB 11.4, MariaDB 11.8): error 1372: ERROR 1372 (HY000) at line 1: Password hash should be a 41-digit hexadecimal number
  • --skip-grant-tables + FLUSH PRIVILEGES; SET PASSWORD FOR ... = PASSWORD('x') (MySQL 8.0, MySQL 8.4, MySQL 9): error 1064: ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PASSWORD('Reset
  • --init-file containing ALTER USER ... IDENTIFIED BY (no skip-grant-tables) (MySQL 5.6): server did not accept the new password after --init-file

Related errors: 1290, 1054, 1348, 1356, 1372

The original article

First published 2011-05-11. The text below is the original; the table above shows how it behaves on current versions.

I have put together a screencast, explaining two ways in which the root password may be changed on a MySQL server. One solution is specific to Linux, the other is a more generic solution that will work on both Windows and Linux. It is assumed that you have the admin/root user and passwords for the respective operating systems.