Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Resetting the Root Password - MySQL

RSS
Modified on Sat, Apr 09, 2016, 1:44 PM by Administrator Categorized as MySQL

Overview

In the case where the password for the "root" account for a MySQL instance running on a Linux machine is lost, the following procedure will allow you to reset the password.

Procedure

The following procedure is adapted from https://www.howtoforge.com/setting-changing-resetting-mysql-root-passwords

1. Connect to the Linux instance via Putty

2. Stop the MySQL instance
sudo service mysqld stop

Or less commonly...

sudo /etc/init.d/mysqld stop

3. Start the MySQL server/daemon so it won't prompt for a password.

sudo mysqld_safe --skip-grant-tables &

4. Log into MySQL as the "root" user

mysql -u root

5. Change the password.

use mysql;
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
flush privileges;
quit

6. Restart MySQL
sudo service mysqld stop
sudo service mysqld start

Or less commonly...

sudo /etc/init.d/mysqld stop
sudo /etc/init.d/mysqld start

7. Test

mysql -u root -p

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2018, Patrick Jasinski.