Thursday, January 31, 2019

How to Reset MySQL root Password in Linux

No comments
Hi Dear Friends,

In this post We would like to share infinity knowladge My Good experience and Best solution For .

Laravel Examples

MySQL is an open source database software widely used for data storage. Sometimes we forgot MySQL root password. So don’t be panic, This tutorial will help you to reset MySQL root password with simple steps.

Step 1 – Start MySQL in Safemode

First of all, you are required to stop running MySQL server. Use one of the following commands to stop MySQL server on your Linux system.
# service mysql stop              //For SysVinit based ystems 
# systemctl stop mysql.service    //For Systemd based Systems 
Now start MySQL server in safe mode using withe the --skip-grant-tables option. Use the following command to start MySQL in safe mode. In safe mode, MySQL does not prompt for login password.
# mysqld_safe --skip-grant-tables &

Step 2 – Reset MySQL root Password

Now login to MySQL server as root user and change password using the following set of commands. This will reset MySQL root password on your system.
For MySQL 5.6 or Below
# mysql -u root

mysql> USE mysql;
mysql> UPDATE user SET password=PASSWORD("NEW-PASSWORD") WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
For MySQL 5.7 or Above
# mysql -u root

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD("NEW-PASSWORD");
mysql> FLUSH PRIVILEGES;
mysql> quit

Step 3 – Restart MySQL Server

After changing password stop the MySQL (running in safe mode) service and start it again with the commands below.
//For SysVinit based systems 
# service mysql stop 
# service mysql start

//For Systemd based systems 
# systemctl stop mysql.service
# systemctl start mysql.service

Step 4 – Verify New Password

After resetting MySQL root account password and restarting, just verify new password by login.
# mysql -u root -p

Enter password: **********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 29
Server version: 5.5.57 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
Try this it will help you and for more information click here: Laravel Examples.

Read :

I hope you like this Post, Please feel free to comment below, your Any Idea, suggestion and problems if you face - I am here to Resolve your Any problems.
We hope it can help you...

No comments :

Post a Comment