Total visit on this blog

Thursday 2 August 2012

Reset MySQL root password

Steps to reset MySQL root password
[root@nischal ~]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user ‘root’@'localhost’ (using password: YES)
Check if the Mysql process is running (its running here)
[root@nischal ~]# ps -ef | grep mysql
mysql 1348 1 0 19:44 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe –basedir=/usr
mysql 1616 1348 0 19:44 ? 00:00:09 /usr/libexec/mysqld –basedir=/usr –datadir=/var/lib/mysql –plugin-dir=/usr/lib/mysql/plugin –log-error=/var/log/mysqld.log –pid-file=/var/run/mysqld/mysqld.pid –socket=/var/lib/mysql/mysql.sock
root 4069 2569 0 22:23 pts/0 00:00:00 grep –color=auto mysql
Time to reset the Mysql root password !!
Stop the mysql service
———————————————————————————————————————————–
[root@nischal init.d]# mysqld_safe –skip-grant-tables &
[2] 4706
[root@nischal init.d]# 120802 22:36:21 mysqld_safe Logging to ‘/var/log/mysqld.log’.
120802 22:36:21 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
————————————————————————————————————————————
[root@nischal init.d]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.25a MySQL Community Server (GPL) by Remi
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql>
————————————————————————————————————————————-
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
————————————————————————————————————————————–
mysql> update user set password=PASSWORD(“Admin@123_”) where User=’root’;
Query OK, 3 rows affected (0.33 sec)
Rows matched: 3 Changed: 3 Warnings: 0
————————————————————————————————————————————-
[root@nischal init.d]# /etc/init.d/mysqld stop
[root@nischal init.d]# /etc/init.d/mysqld start
—————————————————————————————————————————————
Connect to Mysql DB using new password:
[root@nischal ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.25a MySQL Community Server (GPL) by Remi
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql>
—————————————————————————————————————————————–
mysql> show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| mydatabase |
| mysql |
| performance_schema |
+——————–+
4 rows in set (0.00 sec)
——————————————————————————————————————————————-
Enjoy! Now you have root access. :)

No comments:

Post a Comment