2016-03-31T22:34:52
Reset MySQL Root Password
I must have it saved somewhere but it was nowhere to be found. The password was lost. My root account was forever secure--or was it?
# service mariadb stop
# mysqld_safe --skip-grant-tables &
# mysql -u root
> USE mysql
> UPDATE user SET password=PASSWORD("mynewpassword") WHERE User='root';
> FLUSH PRIVILEGES
> QUIT
This didn't stop the mysqld_safe process, so I killed the parent mysql process (/usr/libexec/mysqld
) via its process ID ($pid).
# kill $pid
Start MySQL back up.
# service mariadb start
Finally, for security purposes, remove the UPDATE user ...
SQL statement from ~/.mysql_history
.
Profit! And don't forget to securely store your password.