reset mysql root password from command line Unix/linux

MySQL
MySQL is a Relational Database Management System (RDBMS) that runs as a server providing multi-user access to a number of databases.

Installation:

[[email protected] ~]# yum install mysql-server mysql php-mysql 
[[email protected] ~]# rpm -qa|grep mysql 
php-mysql-5.1.6-40.el5_9 
mysql-5.0.95-5.el5_9 
mysql-server-5.0.95-5.el5_9 

Steps to reset mysql password:
Step 1: Stop mysql server

[[email protected] ~]# service mysqld stop
Stopping mysqld:                               [ OK ]
OR
[[email protected] ~]# /etc/init.d/mysqld stop 
Stopping mysqld:                               [ OK ]

Step 2: Start mysql configuration, Execute the command as mysql safemode:

[[email protected] ~]# mysqld_safe --skip-grant-tables & 

Step 3: Replace old password with the new one from mysql command prompt.

mysql> update user set password=PASSWORD("newpassword") where User='root'; FLUSH PRIVILEGES; exit;

Step 4: Restart mysql server.

[[email protected] ~]# service mysqld restart

Step 5: Access mysql by using new password

[[email protected] ~]# mysql -u root -p
Enter password:

That’s it 🙂

Arunlal Ashok

Linux Server Administrator. I'm dealing with Linux servers since 2012. I started this blog to share and discuss my ideas with the world. Check My Profile!! in uPwork (oDesk) and let me know if you need any assistance. Thanks!!

You may also like...

1 Response

  1. December 27, 2013

    […] Related topics: How to create MySQL dump/backup of all the databases reset mysql root password from command line Unix/linux […]

Leave a Reply

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