Thursday, 14 September 2017

How To Reset MySQL password for phpMyAdmin

Reset MySQL root password

for phpMyAdmin

 
If you want to access phpMyAdmin then MySQL root password is require.


Following steps should help you to reset the password

Firstly, Stop the MySQL Server service :

run these command if one not work try another

/etc/init.d/mysql stop
 or
/etc/init.d/mysqld stop

Second, Start the MySQL configuration:

mysqld --skip-grant-tables &
 or
mysqld_safe --skip-grant-tables &

Third, Login to MySQL as root user :

mysql -u root mysql

Fourth, Execute MySQL command to reset/update the password :

update user set password=PASSWORD("NEWPASSWORD") where User='root'; FLUSH PRIVILEGES; exit;
 
Note: In above query, replace "NEWPASSWORD" with your new password.

Fifth, Stop the MySQL server Service :

/etc/init.d/mysql stop
or
/etc/init.d/mysqld stop

Sixth, Start the MySQL server Service :

/etc/init.d/mysql start
or
/etc/init.d/mysqld start

Seventh, Try logging in MySQL prompt:

mysql -u root -pNEWPASSWORD

Example:

[root@localhost]# /etc/init.d/mysqld stop
Stopping mysqld:                                           [  OK  ]
[root@localhost]# mysqld_safe --skip-grant-tables &
[1] 4721
[root@localhost]# Starting mysqld daemon with databases from /var/lib/mysql
[root@localhost]#
[root@localhost]# mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.2.95 Source distribution
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> update user set password=PASSWORD(password") where User='root';FLUSH PRIVILEGES; exit;
Query OK, 3 rows affected (0.02 sec)
Rows matched: 3  Changed: 3  Warnings: 0
Query OK, 0 rows affected (0.01 sec)
Bye
[root@localhost]# /etc/init.d/mysqld stop
STOPPING server from pid file /var/run/mysqld/mysqld.pid
131450 05:06:25  mysqld ended
Stopping mysqld:                                           [  OK  ]
[1]+  Done                    mysqld_safe --skip-grant-tables
[root@localhost]# /etc/init.d/mysqld start
Starting mysqld:                                           [  OK  ]
[root@localhost]# mysql -u root -ppassword
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.2.95 Source distribution
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> exit
 
 
The above method works on Ubuntu, Fedora, CentOS, RedHat.

In Any case, if Above solution doesn't work then reinstall MySql properly.


Thank You....

No comments:

Post a Comment

Best forums to know about latest technology

Best websites/blogs/forums to know about latest technology For technology Digital Trends Web Trends Technology Technology T...