- As Linux system root user stop the database process: /etc/init.d/mysql stop
(or: service mysql stop) - Start MySQL in safe mode and skip the use of the “grant tables”: /usr/bin/mysqld_safe –user=mysql –socket=/var/lib/mysql/mysql.sock –pid-file=/var/run/mysqld/mysqld.pid –datadir=/var/lib/mysql –skip-grant-tables –skip-networking &
- Reset the MySQL root password: mysqladmin -u root flush-privileges password newpassword
- Stop MySQL running in safe mode: kill `cat /var/run/mysqld/mysqld.pid`
- Start MySQL: /etc/init.d/mysql start
- The new MySQL root password can now be used: mysql -u root -p
Respond withthe password: newpassword
How to recover root password in MySQL?
1 Reply