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
More From Oodles
Ready to innovate? Let's get in touch
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
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.