mysql forgot root password, need reset (very urgent !!!)

Hi experts.

I carelesslly lost my root password. I'm using mysql 4.1.11-win32. CAN anyone help me to reset the password.

Thanks in advance

lilyyan
lilyyanAsked:
Who is Participating?
 
UmeshConnect With a Mentor MySQL Principle Technical Support EngineerCommented:
For complete take a look at here..
http://dev.mysql.com/doc/mysql/en/resetting-permissions.html

For windows...

The procedure under Windows:

Log on to your system as Administrator.

Stop the MySQL server if it is running. For a server that is running as a Windows service, go to the Services manager:

Start Menu -> Control Panel -> Administrative Tools -> Services

Then find the MySQL service in the list, and stop it.

If your server is not running as a service, you may need to use the Task Manager to force it to stop.

Create a text file and place the following command within it on a single line:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPassword');

Save the file with any name. For this example the file will be C:\mysql-init.txt.

Open a console window to get to the DOS command prompt:

Start Menu -> Run -> cmd


We are assuming that you installed MySQL to C:\mysql. If you installed MySQL to another location, adjust the following commands accordingly.

At the DOS command prompt, execute this command:

C:\> C:\mysql\bin\mysqld-nt --init-file=C:\mysql-init.txt

The contents of the init-file are executed at server startup, changing the root password. After the server has started successfully you should delete C:\mysql-init.txt.

Users of MySQL 4.1 and higher who install MySQL using the MySQL Installation Wizard may need to specify a defaults-file:

C:\>C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld-nt.exe --defaults-file="C:\Program Files\MySQL\MySQL Server 5.0\my.ini" --init-file=C:\mysql-init.txt

The appropriate defaults-file setting can be found using the Services Manager:

Start Menu -> Control Panel -> Administrative Tools -> Services

Find the MySQL service in the list, right-click on it, and choose the Properties option. The Path to executable field contains the defaults-file setting.

Stop the MySQL server, then restart it in normal mode again. If you run the server as a service, start it from the Windows Services window. If you start the server manually, use whatever command you normally use.

You should be able to connect using the new password.

0
 
sajuksCommented:
Appendix A of MySQL manual:
=============
A.4.2 How to Reset a Forgotten Root Password

If you never set a root password for MySQL, then the server will not require a password at all for connecting as root. It is recommended to always set a password for each user. See section 4.2.2 How to Make MySQL Secure Against Crackers.

If you have set a root password, but forgot what it was, you can set a new password with the following procedure:

   1. Take down the mysqld server by sending a kill (not kill -9) to the mysqld server. The pid is stored in a `.pid' file, which is normally in the MySQL database directory:

shell> kill `cat /mysql-data-directory/hostname.pid`

      You must be either the Unix root user or the same user mysqld runs as to do this.
   2. Restart mysqld with the --skip-grant-tables option.
   3. Set a new password with the mysqladmin password command:

shell> mysqladmin -u root password 'mynewpassword'

   4. Now you can either stop mysqld and restart it normally, or just load the privilege tables with:

shell> mysqladmin -h hostname flush-privileges

   5. After this, you should be able to connect using the new password.

Alternatively, you can set the new password using the mysql client:

   1. Take down and restart mysqld with the --skip-grant-tables option as described above.
   2. Connect to the mysqld server with:

shell> mysql -u root mysql

   3. Issue the following commands in the mysql client:

mysql> UPDATE user SET Password=PASSWORD('mynewpassword')
    ->             WHERE User='root';
mysql> FLUSH PRIVILEGES;

   4. After this, you should be able to connect using the new password.
   5. You can now stop mysqld and restart it normally.
0
 
lilyyanAuthor Commented:
Hi thanks for your reply.

But I'm usning mysql under windows.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
sajuksCommented:
For windows manual also the answer would've been in Appendix A ;-)
@ushastry has given the rite link
0
 
lilyyanAuthor Commented:
Appreciate your reply !!

>>Users of MySQL 4.1 and higher who install MySQL using the MySQL Installation Wizard may need to specify a defaults-file:

C:\>C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld-nt.exe --defaults-file="C:\Program Files\MySQL\MySQL Server 5.0\my.ini" --init-file=C:\mysql-init.txt

The appropriate defaults-file setting can be found using the Services Manager:

Start Menu -> Control Panel -> Administrative Tools -> Services

Find the MySQL service in the list, right-click on it, and choose the Properties option. The Path to executable field contains the defaults-file setting.

------------
I'm using mysql 4.1.11,

so I used
C:\>"C:\Program Files\MySQL\MySQL Server4.1\bin\mysqld-nt.exe" --defaults-file="
C:\Program Files\MySQL\MySQL Server 4.1\my.ini" --init-file=C:\mysql-init.txt

---------------------------
got the error
The system cannot find the path specified.
0
 
lilyyanAuthor Commented:
Hi sorry there is syntax error, I'm try again .
0
 
lilyyanAuthor Commented:
HI

WHEN I execute :

C:\>"C:\Program Files\MySQL\MySQL Server 4.1\bin\mysqld-nt.exe" --defaults-file="
C:\Program Files\MySQL\MySQL Server 4.1\my.ini" --init-file=C:\mysql-init.txt

the error is :

Can't start server: Bind on TCP/IP port: No error
050510  0:10:02 [ERROR] Do you already have another mysqld server running on por
t: 3306 ?
050510  0:10:02 [ERROR] Aborting

050510  0:10:02 [Note] C:\Program Files\MySQL\MySQL Server 4.1\bin\mysqld-nt.exe
: Shutdown complete

0
 
UmeshMySQL Principle Technical Support EngineerCommented:
Have u stoped the mysql service..? if not then stop it first & then try..also check if there is some other entry for mysql..

Start Menu -> Control Panel -> Administrative Tools -> Services

Then find the MySQL service in the list, and stop it.


Also you can do the same by running the commands..


Start Menu -> Run..

NET STOP mysql (mysql should be the service name)



0
 
lilyyanAuthor Commented:
HI, Really appreicate your suggestions.

Now the password for root has been correct !!

But when I try to use mysql Control Center tool to access the tables I had, I can't.

In the user table the only user is rooT@localhost:3306,
when I try to connect the db, it shows Access denied for' root'@'localhost'(using password YES')

i guess somehow i modified the password before by using mysql Control Center before.

should i reinstall mysql Control Center ?
0
 
UmeshMySQL Principle Technical Support EngineerCommented:
No need to reinstall mysqlcc..just change the connection parameter (only update the password with the new one)..

Hope This helps!
0
 
lilyyanAuthor Commented:
you mean i need change the password into the new one in the editable interface?

i am not sure if i should change, beacuse i don't if it's an encryped password.

it seems i made this mistake before

0
 
lilyyanAuthor Commented:
HI, this is really great !!

Now the everything works fine. Really apprecate your help!!
0
 
UmeshMySQL Principle Technical Support EngineerCommented:
Glad to know that everything works fine..


Thanks,
Umesh Shastry
0
All Courses

From novice to tech pro — start learning today.