how to reset root password mysql on centos

tutorial how to reset root password mysql on centos, do you forgot you password as root on mysql?

you can easy to reset mysql password and you dont need old password, just give new password on script below then run mysql command.

first you needed stop mysql

Type the following command to stop mysql server under RHEL / Fedora / CentOS Linux:

or you can kill mysql, to stop process

after mysql stop and not running, we can create script to reset password mysql

than Append the following code:
UPDATE mysql.user SET Password=PASSWORD('YOUR-NEW-MYSQL-PASSWORD') WHERE User='root';
FLUSH PRIVILEGES;

save that file and close, now we have script reset mysql password on centos
here is command mysql + reset password
mysqld_safe --init-file=/root/mysql.reset.sql &

Sample output:
nohup: ignoring input and redirecting stderr to stdout
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[20970]: started

And you are done with resetting operation. Simply, stop server and start again:

now we have reset old password mysql with new password mysql on centos, dont place this script on your server because anonymous can reset your password,delete that script after using that script. that’s all easy how to reset mysql password centos

Leave a Reply

Your email address will not be published. Required fields are marked *