Reset mysql root password on Centos
- Stop the MySQL daemon : service mysqld stop
- Start MySQL in safe mode with the –skip-grant-tables and -u root options in background : mysqld_safe –skip-grant-tables -u root &
- Start the command line client as root : mysql -u root
- Issue the MySQL command to reset the root password : UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
- Issue the flush privileges command : FLUSH PRIVILEGES;
- Quit the command line tool : quit
- Stop the MySQL process : kill `cat /var/run/mysqld/mysqld.pid`
- Restart the MySQL daemon : service mysqld start
- Log in as root to make sure the new password is active : mysql -u root -p
Here's a screenshot so you can see how it actually goes :
Set / change / reset the MySQL root password on Ubuntu . Enter the following lines in your terminal.
- Stop the MySQL Server.
sudo /etc/init.d/mysql stop
- Start the mysqld configuration.
sudo mysqld --skip-grant-tables &
- Login to MySQL as root.
mysql -u root mysql
- Replace YOURNEWPASSWORD with your new password!
UPDATE user SET Password=PASSWORD('
YOURNEWPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;
No comments:
Post a Comment