Reset MySql Server root user password

RESET MYSQL ROOT PASSWORD PROCESS

 You have to have the sudo/root access to the server

Run the below command to reset the password.

Step 1. STOP the mysql daemon service using "service mysqld stop" "sudo /sbin/service mysqld stop"

Step 2.   mysqld_safe --skip--grant-tables

Step 3. mysql -u root

Step 4.  
mysql> UPDATE mysql.user SET Password=PASSWORD('mysql') WHERE User='root';
Query OK, 2 rows affected (0.00 sec)
Rows matched: 3  Changed: 2  Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

Add one more user

mysql> create user 'aravi'@'localhost' IDENTIFIED BY 'mysql';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'aravi'@'localhost'
    -> WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql> show grants for 'aravi'@'localhost';
+----------------------------------------------------------------------------------------------------------------+
| Grants for aravi@localhost                                                                                     |
+----------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'aravi'@'localhost' IDENTIFIED BY PASSWORD '68d4f47c49a579c9' WITH GRANT OPTION |
+----------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> quit

Password reset for root user is done. Now restart the mysqld service.

sudo /sbin/service mysqld restart
service mysqld restart

Enjoy.......

No comments:

Post a Comment