Go Back   Computer Forums > Articles | Tutorials | Tech Notes > Articles | Networking, Internet and Social Media
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 01-02-2011, 06:47 AM   #1
In Runtime
Join Date: Jan 2011
Posts: 277
Default Step by step guide for Resetig the mysql database root password in Linux

Mysql installation time, If you have never set a root password for MySQL, the server does not require a password at all for connecting as root. To setup root password for first time, use mysqladmin command at shell prompt as follows:


$mysqladmin -u root password NEWPASSWORD

However, if you want to change (or update) a root password, then you need to use following command


$ mysqladmin -u root -p 'oldpassword' password newpass

For example, If old password is computer, and set new password to computerforum, then press enter

$ mysqladmin -u root -p 'computer' password 'computerforum'

Other then the ways specified here to reset and change the root password for mySQL in the case that the password is forgotten or lost.


1)Stop the mysql demon process using this command

sudo /etc/init.d/mysql stop
2)Start the mysqld demon process using the –skip-grant-tables option with this command

sudo /usr/sbin/mysqld –skip-grant-tables –skip-networking &

3)start the mysql client process using this command

mysql -u root

from the mysql prompt execute this command to reset/update your password
SET PASSWORD FOR root@’localhost’ = PASSWORD(‘password’);

If you have a mysql root account that can connect from everywhere, you should also do:
UPDATE mysql.user SET Password=PASSWORD(‘newpwd’) WHERE User=’root’;
Alternate Method:
USE mysql
UPDATE user SET Password = PASSWORD(‘newpwd’)
WHERE Host = ‘localhost’ AND User = ‘root’;
And if you have a root account that can access from everywhere:
USE mysql
UPDATE user SET Password = PASSWORD(‘newpwd’)
WHERE Host = ‘%’ AND User = ‘root’;

For either method, once have received a message indicating a successful query (one or more rows affected), flush privileges:

Then stop the mysqld process
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
sahabcse is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 01:00 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0