Link to home
Start Free TrialLog in
Avatar of workflow80
workflow80

asked on

root password mysql

Hi

We have installed mysql in a windows 2003 server.

We have lost the root password. How to recover it and change it?
We don't have phpmyadmin.

Thanks.
Avatar of Anil
Anil
Flag of United Kingdom of Great Britain and Northern Ireland image

Please try

http://downloads.mysql.com/docs/mysql-windows-excerpt-5.1-en.pdf/

Chapter 4.

Hope this helps.
A>
You did not mention which version of mysql you have ?

A>
Avatar of MarioAlcaide
MarioAlcaide

How to Reset a MySQL Password in 5 Easy Steps

   1.

      Stop the mysqld daemon process.
   2.

      Start the mysqld daemon process with the –skip-grant-tables option.
   3.

      Start the mysql client with the -u root option.
   4.

      Execute the UPDATE mysql.user SET Password=PASSWORD(‘password’) WHERE User=’root’;
   5.

      Execute the FLUSH PRIVILEGES; command.
In case you forgot the root password for your MySQL database server running under Microsoft Windows, you can still access your database and even reset your password using the command prompt. However, first you should check your my.cnf file where your password is stored.

If you are using a new version of MySQL Server, such as 5.0, the methods here might not work for you, or slightly different actions may need to be applied.

1. Stop your MySQL server completely. This can be done by accessing the Services window inside Windows XP and Windows Server 2003, where you can stop the MySQL service.

2. Open your MS-DOS command prompt using "cmd" inside the Run window. Inside it navigate to your MySQL bin folder, such as C:\MySQL\bin using the cd command.

3. Execute the following command in the command prompt: mysqld.exe -u root --skip-grant-tables

4. Leave the current MS-DOS command prompt as it is, and open a new MS-DOS command prompt window.

5. Navigate to your MySQL bin folder, such as C:\MySQL\bin using the cd command.

6. Enter "mysql" and press enter.

7. You should now have the MySQL command prompt working. Type "use mysql;" so that we switch to the "mysql" database.

8. Execute the following command to update the password:

UPDATE user SET Password = PASSWORD('NEW_PASSWORD') WHERE User = 'root';

However, you can now run any SQL command that you wish.

After you are finished close the first command prompt and type "exit;" in the second command prompt windows to disconnect successfully. You can now start the MySQL service.
ASKER CERTIFIED SOLUTION
Avatar of mwiercin
mwiercin

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

ASKER

Hi

I've tried to do what is written in http://downloads.mysql.com/docs/mysql-windows-excerpt-5.1-en.pdf
It seems the same thing as you have explained
however i got a message ( see image).

any idea ?

thanks.


 User generated image
Hi,

It seems fine for me, mysql is running, it just complained about deprecated option. Have you tried connecting to it from the other window (mysql -h127.0.0.1 using command line client)? If it doesn't work try running:

netstat -a -n -p tcp

, and check whether you can see the row like:

 TCP    0.0.0.0:3306            0.0.0.0:0              LISTENING

Open in new window


The part after colon in the second column is important  - should match 3306 with MySQL's default settings, and it should also say LISTENING. If your database is accepting network connections (even if only localhost ones) you should have it there.
@mwiercin

Yes, I got this row.
Hi,

Are you able to connect by running
mysql -h127.0.0.1 -P3306

Open in new window

?

If not... try killing the server, use taskmgr to get process list, and simply kill it. Now, locate mysqld binary - I'm not really into Windows hosted MySQL, but you should have something like c:\mysql\bin\mysqld. Once you've done it start it again by running:

mysqld --skip-grant-tables --port=3306 --bind-address=127.0.0.1

Open in new window


And try to connect using the command at the top of the post.