Link to home
Start Free TrialLog in
Avatar of lilyyan
lilyyan

asked on

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
Avatar of sajuks
sajuks

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.
Avatar of lilyyan

ASKER

Hi thanks for your reply.

But I'm usning mysql under windows.
ASKER CERTIFIED SOLUTION
Avatar of Umesh
Umesh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
For windows manual also the answer would've been in Appendix A ;-)
@ushastry has given the rite link
Avatar of lilyyan

ASKER

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.
Avatar of lilyyan

ASKER

Hi sorry there is syntax error, I'm try again .
Avatar of lilyyan

ASKER

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

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)



Avatar of lilyyan

ASKER

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 ?
No need to reinstall mysqlcc..just change the connection parameter (only update the password with the new one)..

Hope This helps!
Avatar of lilyyan

ASKER

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

Avatar of lilyyan

ASKER

HI, this is really great !!

Now the everything works fine. Really apprecate your help!!
Glad to know that everything works fine..


Thanks,
Umesh Shastry