Jesin's Blog

Welcome to the Portal of Technology

  • Facebook
  • GitHub
  • Google+
  • RSS
  • Twitter
  • Home
  • Categories
    • Domains
    • Linux
    • Networking
    • PHP
    • Virtualization
    • Web Design
    • Web Servers
    • Windows
  • WordPress Plugins
    • Custom Error Pages
    • HTTP Digest Authentication
    • Mailgun Email Validator
  • Toolbox
    • DNS Lookup Tool
    • htdigest Generator Tool Online
    • htpasswd Generator Tool Online
    • HTTP Headers Lookup Tool
    • MD5 Encryption Tool
    • Open Port Check Tool
    • SHA-1 Encryption Tool
    • URL Encoding/Decoding Tool
  • About Me
  • Contact Me
  • Sitemap
Home ›
Windows ›
Resetting MySQL root password in Windows

Resetting MySQL root password in Windows

March 19, 2011 Windows Jesin A Leave a Comment

forgot mysql password windows smiley

This tutorial describes how to reset the MySQL root user password if the root password is forgotten. The procedure in windows involves creating a new file which contains a query to UPDATE the MySQL root user’s password from the table named ‘user’ and then start the MySQL process again. Before starting check whether MySQL is running as a service or as a process. To check this got to start -> run or [windows] + R and type services.msc. If you find a service named MySQL or something similar to wampmysql then MySQL is running as a service right click it and stop it. Else open task manager and locate a process named mysqld and “End” the process. If you’re using Linux read this article.

Open a text editor and type the following two queries.

UPDATE mysql.user SET password=PASSWORD('newpassword') WHERE user='root';
FLUSH privileges;

Replace newpassword with your desired password to be reset. Save the file with preferably a .sql extension on the local hard drive.

After MySQL is stopped open the command-line by typing cmd in run. Navigate to your MySQL installation bin folder by using the cd command

cd "C:\MySQL Server 5.1\bin"

if you don’t know where you installed MySQL open the MySQL service properties window and locate it.

locate mysql installation folder
Locate the MySQL installation location from the service properties window

Now issue the command to start the MySQL server with the initialization file.

mysqld.exe --defaults-file="C:\MySQL Server 5.1\my.ini" --init-file="C:\file.sql" --console

The defaults-file contains the configuration for MySQL if you don’t know where this file is see the MySQL service properties window. The init-file option is the path to the queries file created in the previous step. The console option displays the output in the command line.

reset mysql root password
Reset the MySQL root user password

After you see the above screen close the command line and start the MySQL service or process. Try connecting using the updated root password through the command line from inside the bin folder.

mysql.exe -u root -p

You’ll be prompted for the new password enter it and login. To change the MySQL root password type these queries.

UPDATE mysql.user SET password=PASSWORD('secure_password') WHERE user='root';
FLUSH privileges;

Replace secure_password with a new very very secure password. Do the necessary changes in your scripts. After the completion of all the steps remove the .sql file containing queries to change the MySQL root password immediately.

Related posts:

linux category thumbnailForgot MySQL root user password (Linux) linux category thumbnailReset Root Password in Linux php category thumbnailHow to reset the Joomla Administrator password linux category thumbnailHow to set a GRUB password connect php with mysql thumbnailConnect PHP with MySQL

Tags: mysql

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Get a wealth of information delivered to your inbox. Subscribe and never miss a single article.

  • Tutorials and howtos
  • Code, scripts and commands
  • Online Tools

* No spam, unsubscribe anytime

Hire Me

  • SSL installation and hardening (A+ on Qualys SSL test)
  • Apache & Nginx configuration
  • Email deliverability improvement (10/10 on Mail Tester & MailGenius)
  • WordPress customization, optimization and migration
  • and much more…

    Tools

    • DNS Lookup Tool
    • htdigest Generator Tool Online
    • htpasswd Generator Tool Online
    • HTTP Headers Lookup Tool
    • MD5 Encryption Tool
    • Open Port Check Tool
    • SHA-1 Encryption Tool
    • URL Encoding/Decoding Tool

    Nav

    • Home
    • About Me
    • Contact Me
    • Privacy Policy
    • Sitemap
    Vultr SSD VPS

    Creative Commons License
    Jesin's Blog by Jesin A is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
    Based on a work at websistent.com.