Forgot your MySQL Password? No worries

Step 1 – Stop mysql service
# /etc/init.d/mysql stop
You should see something like this
Stopping MySQL database server: mysqld.

Step 2 – Start MySQL server with out password
# mysqld_safe --skip-grant-tables &
You can also run
service mysql start --skip-grant-tables
You should see something like this
Starting MySQL.. SUCCESS!

Step 3 – Connect to mysql server using root user
# mysql -u root

You will see something like this
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.1.55-MariaDB-mariadb98 (MariaDB - http://mariadb.com/)

This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [(none)]>

Step 4 – Set up new MySQL password for the root user
MariaDB [(none)]> use mysql;
MariaDB [mysql]> update user set password=PASSWORD("9nji77~") where User='root';
MariaDB [mysql]> flush privileges;
MariaDB [mysql]> quit

Step 5 – Stop MySQL Server
# /etc/init.d/mysql stop
You should see something like this
Stopping MySQL database server: mysqld.

Step 6 – Start MySQL Server and test

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.