Home mysql-resetting-root-password
Post
Cancel

mysql-resetting-root-password

  • kill mysql
  • create a file with the following lines in it;
1
2
UPDATE mysql.user SET Password=PASSWORD('') WHERE User='root';
FLUSH PRIVILEGES;
  • start mysql passing in init file;
1
mysqld_safe --init-file=/tmp/mysql-init &

check /var/log/mysqld.log to ensure it started and ran your file

  • should be able to log in now with empty password and set a more secure one.
  • kill mysql once more (kill `cat /mysql/data/mysql.pid`) then restart as normal
This post is licensed under CC BY 4.0 by the author.