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.


[root@server ~]# yum install mysql-server mysql php-mysql 
[root@server ~]# rpm -qa|grep mysql 

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

[root@server ~]# service mysqld stop
Stopping mysqld:                               [ OK ]
[root@server ~]# /etc/init.d/mysqld stop 
Stopping mysqld:                               [ OK ]

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

[root@server ~]# 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.

[root@server ~]# service mysqld restart

Step 5: Access mysql by using new password
[root@server ~]# mysql -u root -p

Enter password:

  • 0 Users Found This Useful
Was this answer helpful?
Related Articles

Powered by WHMCompleteSolution

Copyright © 2019 Công ty TNHH KDATA. All Rights Reserved.