Monday, July 13, 2009

mysql password reset in 10 steps

suppose u forgot the password of u'r mysql server
while u are trying to logged in it will display a message like
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
so here is a solution to change the password of mysql with out loss of u'r data
first you have to stop the mysqld service
1)service mysqld stop

then u have to find out the mysqld path
2) whereis mysqld
it will display the mysqld location in your system
Then u have to run the mysqld with the option --skip-grant-tables

3)/usr/libexec/mysqld --skip-grant-tables

then the mysql will be started
090713 13:15:33 InnoDB: Started; log sequence number 0 11427172
090713 13:15:33 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.0.45' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution

Now u can login to mysql with out using password using a client
4)mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

after that u have to choose the mysql as your database
5)use mysql
in mysql database the user table contains the login details of the user

to see the structure of the table "user" just input
6)desc user

u have to use update command to change the password of a user
7)update user set password=password('test123') where user='root';
this will set the password of root to test123

8)flush privilges
;

kill the mysqld u have started
9)killall -9 mysqld
start mysqld service again

10)service mysqld start

now u can login to the mysql root account using test123 as password

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails