Tuesday, October 20, 2020

How to reset the MySQL 5.7 root password in Ubuntu linux

 How to reset the MySQL 5.7 root password in Ubuntu linux


MySQL is an open-source relational database management system. Its name is a combination of "My", the name of co-founder Michael Widenius's daughter, and "SQL", the abbreviation for Structured Query Language.

If you forget your mysql server root passowrd, dont worry please use below commands. 

1) Open Terminal

* stop mysql service

$ sudo service mysql stop


2) Create MySQL service directory

$ sudo mkdir /var/run/mysqld


3) Give MySQL user permission to write to the service directory


$ sudo chown mysql: /var/run/mysqld


4) Start MySQL manually, without permission checks or networking


$ sudo mysqld_safe --skip-grant-tables --skip-networking &


5) Log in the Mysql Server without a password


$ mysql -uroot mysql


MySQL commands::::::::::::::::::::::::::::::::::


UPDATE mysql.user SET authentication_string=PASSWORD('ENTER_YOUR_PASSWORD_HERE'), plugin='mysql_native_password' WHERE User='root';


EXIT;


Open terminal


1) # Turn off MySQL.


$ sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown


2) Start the MySQL service.


$ sudo service mysql start


3) Now connect the Mysql Server from updated password.


$ mysql -u root -p


No comments:

Post a Comment

testing