Home > Linux > reset forgotten mysql password

reset forgotten mysql password

To reset a forgotten mysql password, log in as root then find and kill the mysqld process

ps -e mysqld | grep mysqld

sudo kill -9 <mysqld-process-id>

now create a file in your home folder, “mysql-reset.txt” for example, and put these two lines in it

UPDATE mysql.user SET Password=PASSWORD(‘the-new-password’) WHERE User=’root’;
FLUSH PRIVILEGES;

then go back to the prompt and run

mysqld_safe –init-file=/path/to/the/file/mysql-reset.txt &

Advertisement
Categories: Linux
  1. No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.