Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

root password mysql

Posted on 2011-03-03
9
Medium Priority
?
431 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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
 
LVL 3

Accepted Solution

by:
mwiercin earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

604 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