Sunday, November 17, 2013

Resetting the MYSQL Root Password

1.
[root@rak3 Mysql Binaries]# ps -ef | grep mysqld
root      7742     1  0 18:31 pts/3    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/rak3.saravanan.com.pid
mysql     7833  7742  0 18:31 pts/3    00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/rak3.saravanan.com.err --pid-file=/var/lib/mysql/rak3.saravanan.com.pid
root      8685  6545  0 18:53 pts/3    00:00:00 grep mysqld


2.
[root@rak3 Mysql Binaries]# mysql -u root -p 
Enter password:                                                ----> password is not accepting
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)


3.
[root@rak3 Mysql Binaries]# sudo /etc/init.d/mysql stop
Shutting down MySQL.                                       [  OK  ]


4.
[root@rak3 Mysql Binaries]# mysqld_safe --skip-grant-tables &
[1] 5988
130429 18:58:21 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql


5.
[root@rak3 Mysql Binaries]# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.31 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, 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.


6.
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


7.
mysql> update user set password=PASSWORD("mysqlbcp") where User='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0


8.
mysql> flush privileges;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'privilages' at line 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye


9.
[root@rak3 Mysql Binaries]# /etc/init.d/mysql stop
Shutting down MySQL.130429 19:01:58 mysqld_safe mysqld from pid file /var/lib/mysql/rak3.saravanan.com.pid ended
                                                           [  OK  ]
[1]+  Done                    mysqld_safe --skip-grant-table


10.
[root@rak3 Mysql Binaries]# /etc/init.d/mysql start
Starting MySQL..                                           [  OK  ]


11.
[root@rak3 Mysql Binaries]# mysql -u root -p 
Enter password:                                                         -->enter the update password  : mysqlbcp
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.31 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, 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> 

No comments:

Post a Comment