Solved

root password mysql

Posted on 2011-03-03
9
429 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
Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

A quick step-by-step overview of installing and configuring Carbonite Server Backup.
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

705 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