reset mysql root password from command line Unix/linux

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


[[email protected] ~]# yum install mysql-server mysql php-mysql 
[[email protected] ~]# rpm -qa|grep mysql 

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

[[email protected] ~]# service mysqld stop
Stopping mysqld:                               [ OK ]
[roo[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 🙂

Post navigation

Arunlal Ashok

Operations Engineer at Endurance International Group. Linux lover. Like to play on Linux console. I started this blog to share and discuss Linux thoughts.

Always happy for an open discussion! Write to arun (@) crybit (dot) com. Check about me for more details. About this blog and our strong members, check The team
Please follow the LinkedIn page

One thought on “reset mysql root password from command line Unix/linux

Leave a Reply

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