|
MySQL: MySQL user accounts | MySQL Console | MySQL phpMyAdmin | MySQL Extra Database | MySQL Lost Password | MySQL Error 1067 |
| MySQL: General information. |
Lost Password
Recently I had a friend, who lost his MySQL password. What he had done was to use phpMyAdmin and changed the root user password.
On refreshing the page received this error message:
#1045 - Access denied for user 'root'@'localhost' (using password: YES)
He then went into apanel used MySQL Server Configuration to set this new password and received the following error message:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in W:\home\admin\www\mqsetup.php on line 46
Error connecting to mysql
Not a real problem:
Note: The same password must be used in each of the above steps.
Unfortunately the above failed because he could not remember the password he set using phpMyAdmin.
One way to recover from this situation is to reset Uniform Server to a know state. The remainder of this page provides a step-by-step guide on how to set the root user password either back to root (default) or to a new password.
To access the MySQL server phpMyAmin uses the root password this it picks up from a file. Before doing anything else edit the file to contain the new password (root) as follows.
The MySQL server requires restarting with skip grant table option set, this bypasses any security allowing access to the server. A new password is set and grant tables updated. The following method uses two command windows and task manger before following each step start the servers using Server_Start.bat I will assume the server is running on drive W.
Open windows task manager by pressing ctrl, alt and del keys together. In the window that opens click on the Process tab (default) scroll up or down and locate the file mysqld-opt.exe right click on this and select End Process click Yes to confirm kill process.
The MySQL server requires restarting (from MySQL console) with skip grant table option set as follows:
Dialogue in the command prompt looks similar to this:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\mpg>w:
W:\>cd usr\local\mysql\bin
W:\usr\local\mysql\bin>mysqld-opt --skip-grant-tables --user=root
-
Start a second command prompt set new password (root) and update grand tables as follows:
Dialogue in the command prompt looks similar to this:
Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\mpg>w:
W:\>cd usr\local\mysql\bin
W:\usr\local\mysql\bin>mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.41-community-nt MySQL Community Edition (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> USE mysql;
Database changed
mysql> UPDATE user SET password=password("root") WHERE user="root";
Query OK, 1 row affected (0.11 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.16 sec)
mysql> exit
Bye
W:\usr\local\mysql\bin>
Final steps:
Resetting the server to a known condition requires a large number of steps if you do make a mistake repeat all steps from the beginning.
Command-line tools are very useful if you do find you are locked out from phpMyAdmin remember these tools are there to be used.
| | Ric |
Categories: UniCenter | MySQL | Support