Solved

root password mysql

Posted on 2011-03-03
9
426 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Backup DHCP Server 8 94
sql select time convert to  time to   a   b mysql 4 40
inplace upgrade from Windows 2003 R2 to 2012 8 49
updating the date data 12 21
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

911 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

18 Experts available now in Live!

Get 1:1 Help Now