Home Home
Restore the MySQL Root User in a WAMP Setup

Reset the Root User or Password in a MySQL WAMP Setup

August 4, 2010 in Development

Running MySQL in a Windows XAMPP test environment is pretty common. Having to restore the root user, or having to reset the root user password, however, is not. Here’s how to get your root user back up and running on your WAMP system in no time.

You’ll need to be logged in as an administrator.

Stop the Service, Kill the Process

The first thing that needs to be done is to stop the MySQL service. You can do this by either going to Windows Services, or just killing the process in Task Manager/Process Explorer. The easy way is to bring up Task Manager, find mysqld.exe, and kill it (delete key).

If that fails, go to Start -> Control Panel -> Administrative Tools -> Services, or type services.msc in the Run box. Right-click on the MySQL service, and select Stop. Poof!

Create a Text File

Open up notepad or your favorite text editor.

If you have a root user and you’re just trying to change the password, copy and paste this into the document:

UPDATE mysql.user SET Password=PASSWORD(‘TEST’) WHERE User=’root’;
FLUSH PRIVILEGES;

Otherwise, if you deleted your root user, try this:

INSERT INTO mysql.user (Host, User, Password, Select_priv, Update_priv, Create_priv, Insert_priv, Reload_priv, Grant_priv, Create_user_priv) VALUES (‘%’, ‘aroot’, PASSWORD(‘TEST’), ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’);
FLUSH PRIVILEGES;

These must be on two separate lines! Also note that you can change the root password by modifying the TEST password in the examples.

Save your document as C:\mysql.txt. Or whatever you feel like naming it.

Start mysqld via Command Line

Open up the command prompt by typing in cmd in the Run box.

Next type in C:\xampp\mysql\bin\mysqld –defaults-file=”C:\\xampp\\mysql\\bin\\my.ini” –init-file=”C:\\mysql.txt” –console. You’ll need to change the directory to fit your XAMPP\mysql\bin directory (by default, it should be C:\xampp\mysql\bin). Also note the double backslashes.

You should get something like this: (note that my paths are slightly different)

Running mysqld.exe manually with the --init-file option should fix your troubles.

Running mysqld.exe manually with the --init-file option should fix your troubles.

If you get any errors, check your paths and your syntax and try again.

Otherwise, you should be successful! Fire up HeidiSQL and connect to 127.0.0.1 as root/TEST. Not only should you get in, you should also be able to create new users with full privileges.

***

Submit to reddit!  Digg!  Like this on Facebook!  Tweet this!

Tags

, ,

Got Something To Say?


angbox: version 5

Subscribe!

Subscribe!


Subscribe to this blog: RSS, Atom
 
angbox

About angbox


Angbox is the personal blog of Cary Ang, a web developer from New Jersey, and an attempt to write about the random things that move him.
 
php.angbox: now open

php.angbox


A laudable effort to teach practical PHP to programmers and non-programmers alike.

The Blog

6

Development


29

Featured


8

Gaming


3

Music


5

Other


6

Personal Finance


19

Travel


Featured Posts

This is Carly Rae Jepsen's EP. LISTEN TO IT NOW.

Curiosity (2012) - Carly Rae Jepsen: Catchy at its Finest


So, there's this new girl in town. Her name's Carly Rae Jepsen. She's Canadian, and she just joined Justin Bieber's new label....
 
AT&T's data plans. FUUUUUUUUUUUUUUUU...

Getting Around AT&T's Tiered Smartphone Data Plans


You've probably heard that AT&T's $30 unlimited* data plans have been dead and gone since the middle of last year, replaced wi...
 
Yet another gate in Togakushi.

22 Days in Japan, Day 18: Exploring Togakushi


It's a dark, cloudy day. The sun is nowhere to be found in Nagano. Since the ryokan (Japanese inn) that I'm currently stayi...
 
Nagano

22 Days in Japan, Day 17: Nagano, Rain, and a Scary Bridge


Kyoto is now miles away, and I'm on the train to my next destination: Nagano. Yep, the same Nagano that hosted the 1998 Winter...
 

Other Fun Angbox Sites

Clear Note Widget

Clear Note Widget


Clear Note Widget is a sticky note and Post-it app for Android phones. Get it now!
 
PennyToSave

PennyToSave


Hundreds of ways to save money on practically everything.
 
randomlygifted

randomlygifted


Let randomlygifted find you the perfect (random) gift ideas.
 
The Nokia Phone Blog

The Nokia Phone Blog


My blog covering the latest developments in the wireless industry, Symbian/MeeGo, and Nokia phones.
 
MyDealSpy

MyDealSpy


The greatest deal aggregator that has ever existed. Okay, I'm a little biased here.
 
PhoneMatchup

PhoneMatchup


An eBay cell phone comparison shopping/price monitoring project. Buy your next cell phone through PhoneMatchup and save!