Change MySql ROOT password

Posted By : Kamaldeep Singh | 12-Jan-2017

Change MYSQL Root Password

Hi.. If you ever forgot the MySQL root user password and can’t remember and wanna break, then you can reset the MySQL database password from the command line. But make sure you must know any of the user and password of the system you are on, this is for MySQL 5.7 onwards:

Step 1: First stop the MySQL using the following command:

sudo service mysql stop

Step 2: Start the MySQL in safe mode:

sudo mysqld_safe --skip-grant-tables

Step 3: This will be an ongoing command until the process is finished so open another shell/terminal window, and log in without a password as root:

myself -u root

Step 4: Flush all the privileges as:

FLUSH PRIVILEGES;

Step 5: Alter the root user password:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

Step 6: Quit the MySQL terminal: \q

step 7: Restart the MySQL services:

sudo service MySQL restart

Thats all you need to do. Now your root user's password will be updated with what you have provided.
Thanks

About Author

Author Image
Kamaldeep Singh

Kamaldeep is a highly skilled Backend Developer specializing in Java, specifically the Spring framework. He also has extensive knowledge of Javascript and associated frameworks such as Node.js and Express. He possesses a deep understanding of the latest technologies and has hands-on experience with Core Java, Spring Boot, Hibernate, Apache Kafka messaging queue, Redis, as well as both relational databases like MySQL and PostgreSQL and non-relational databases like MongoDB. He has made significant contributions to various projects, including Viral Nation, ExamWorks, TNIBRO, Biogas engineering, SecureNow - Web Application, FB Messenger Chatbot, Dialogflow Chatbot, and Catalyst. Kamaldeep's expertise allows him to seamlessly integrate different technologies into applications, highlighting his adaptability and innovative mindset. His practical experience and strong technical skills make him an invaluable asset to any team.

Request for Proposal

Name is required

Comment is required

Sending message..