MySQL: Reset root password

less than 1 minute read

This post is in 'notes'. It means it is not as structured as usual. This kind of posts are only personal notes about interesting things and problems I encounter.



Did you forgot what password your mysql root user uses? Let’s reset it!

To reset root password in mysql follow these steps:

  • Kill mysql sudo kill MYSQL_PROCESS_ID
  • Create text file with this content:
    SET PASSWORD FOR 'root'@'localhost' = PASSWORD('NEW PASSWORD');
    
  • Run sudo mysqld_safe --init-file=/path/to/created/file --skip-syslog &
  • Remove the file
  • Now you should be able to login as root with the new password

Leave a Comment