Reset your MySQL Admin Password

How to reset your MySQL Admin Password

You have installed MySQL and now you are having a hard time remembering the password, what should we do? Lets reset the MySQL root password.

You will need to login as the root user

First: Need to stop MySQL

/etc/init.d/mysql stop

or

killall mysql

Second: Create a msyql password sql script

vim /root/mysql.reset.sql

Append the following code:

UPDATE mysql.user SET Password=PASSWORD('YOUR-NEW-MYSQL-PASSWORD') WHERE User='root';
FLUSH PRIVILEGES;

Save and close the file

Third: Set the new mysql root password

mysqld_safe --init-file=/root/mysql.reset.sql &

Output should be:

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

And now you are done resetting the mysql root password

Now simply stop and restart mysql

killall mysqld
/etc/init.d/mysql start
 
  • 3 användare blev hjälpta av detta svar
Hjälpte svaret dig?

Relaterade artiklar

CentOS One Liner Commands

Centos Oneliners kill all pts for x in $(ps aux | grep pts| awk '{print $2}'); do kill...

Install Remi and EPEL yum repo Centos 7

Install Yum EPEL and Remi repositories on Centos 7 Adding additional useful repo's on Centos 6...

How do I SSH into my VPS? (OS X/Terminal)

If you are on a Mac, SSH-ing into your VPS is very simple. Simply launch "Terminal" by going to...

How To Add Date and Time To Bash History

As Linux users and engineers, we often have to look back in our bash history to figure out...

How do I reset my root password?

To reset your VPS root password, enter the VPS management panel at...