How To Reset Forgotten MySQL Root Password

So you have chosen an awesome cryptic password that not even you can remember! It happens to us all, but fear not, it’s quite a simple job to reset this. Not sure if we should be worried over how easy it is to reset the root password for your mysql server, but we wont complaint for the moment.

So first thing you need to do to be able to do this is have root shell access to your server. The following commands are specific to Red Hat/Centos, but the same process can be used for any linux distro if you update the command accordingly.

Once you are connected to your server you must disable mysql.

service mysqld stop

Now that it is stopped you can enter the following command

mysqld --skip-grant-tables --user=root

You should now have access to update the internal tables for SQL. Now you can log into mysql and reset the password. The semi colon at the end of the line is important! Otherwise the command will keep going with an arrow. I.e ‘->’

 

mysql -u root

UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
FLUSH PRIVILEGES;
quit

Now you should be able to start the server back up.

service start mysqld

Related Articles

Related Questions

Tips for Starting My Kubernetes Certification Journey

Hey everyone! I'm about to dive into my Kubernetes certification journey but I'm feeling a bit lost on where to start. I have some...

What’s the Best SSD for Gaming?

I'm thinking about getting an SSD specifically for gaming, but I'm confused by all the conflicting reviews online. Is there a genuine difference in...

Issues After Upgrading to Ubuntu 22.04 – Docker Doesn’t Work

I recently performed a full upgrade of my virtual machine running Ubuntu 22.04 after not updating for about three months. Unfortunately, after the reboot,...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Latest Tools

OpenAI Token Calculator

This tool is a simple OpenAI token calculator, web-based utility designed to help you quickly estimate the number of tokens in your text when...

List Sorting Tool

Welcome to our innovative list ordering and management tool. This next-level platform enables you to sort a list of items in ascending or descending...

Sudoku Solver

Welcome to our free online Sudoku solving tool, an interactive platform for puzzle enthusiasts seeking a break from a Sudoku conundrum. This advanced platform...

Apply Image Filters To Image

Digital imagery in the modern world is all about reinforcing emotions and stories behind each photo we take. To amplify this storytelling, we are...

Add Watermark To Image

As the world is increasingly consumed by digital media, protecting your original images is paramount. We are thrilled to introduce you to our innovative...

CSV To Xml Converter

Welcome to our CSV to XML converter tool, a convenient and user-friendly solution for all your data conversion needs. This versatile tool on our...

Latest Posts

Latest Questions