MySQL is an open source database software widely used for websites storage. Some times we forgot our MySQL root account password. This article will help you to reset root account password with simple steps.
Step 1: Stop MySQL
Firstly stop MySQL server using following commands.
# service mysqld stop or # systemctl stop mysql.service
Step 2: Start MySQL in SafeMode
Now start MySQL server in safe mode using following command. while starting mysql in safe mode it will not prompt for password.
# mysqld_safe --skip-grant-tables &
Step 3: Reset MySQL root Password
Now login to mysql server using root user and change password using following set of commands.
# mysql -u root mysql> use mysql; mysql> update user set password=PASSWORD("NEW-PASSWORD") where User='root'; mysql> flush privileges; mysql> quit
Step 4: Restart MySQL
After changing password stop mysql (running in safe mode) and start it again
# service mysqld stop # service mysqld start
Step 5: Verify New Password
After resetting mysql root account password and restarting, just verify new password by login.
# mysql -u root -p Enter password:
**********Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 51 Server version: 5.5.34 MySQL Community Server (GPL) by Remi Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql<