Solved

root password mysql

Posted on 2011-03-03
9
425 Views
Last Modified: 2012-05-11
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.
0
Comment
Question by:workflow80
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 6

Expert Comment

by:akajohn
ID: 35028677
Please try

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

Chapter 4.

Hope this helps.
A>
0
 
LVL 6

Expert Comment

by:akajohn
ID: 35028681
You did not mention which version of mysql you have ?

A>
0
 
LVL 4

Expert Comment

by:MarioAlcaide
ID: 35028693
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.
0
 
LVL 4

Expert Comment

by:MarioAlcaide
ID: 35028710
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.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 3

Accepted Solution

by:
mwiercin earned 500 total points
ID: 35030049
MarioAlcaid - you need to do FLUSH PRIVILEGES prior to running UPDATE mysql.user. Also the  better way is use GRANT syntax as opposed to UPDATE (as it will create a new user). So.

1. Stop MySQL
2. Start it with --skip-grant-tables
3. Log in
4. FLUSH PRIVILEGES  (don't log out after that)
5. GRANT ALL ON *.* to 'root'@'localhost' identified by 'random_password';  <--- allows socket connections
6. GRANT ALL ON *.* to 'root'@'127.0.0.1' identified by 'random_password';  <--- allows network localhost connections
7. Stop Mysql
8. Start it without --skip-grant-tables
9. Enjoy....
0
 

Author Comment

by:workflow80
ID: 35031466
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.


 root
0
 
LVL 3

Expert Comment

by:mwiercin
ID: 35031828
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.
0
 

Author Comment

by:workflow80
ID: 35036198
@mwiercin

Yes, I got this row.
0
 
LVL 3

Expert Comment

by:mwiercin
ID: 35040745
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.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now