I

f you read the recent hack of the week on resetting a lost root password for Linux, then you might also be interested in how to reset the password for a MySQL/MariaDB instance. You might need to do this because your DBA left the company, you need to hack the DB, or you simply typo’d the password (let's forget I said hack the DB).

Step 1 : Stop the DB

First, you need to stop the database using systemctl stop mariadb:

Step 2: Start the DB with Recover Options

Next, you will restart the database without networking (since there is no password required) and with skipping grant tables using sudo mysqld_safe --skip-grant-tables --skip-networking &

Step 3: Connect and Reset

Connect to the database without a password using:  mysql -uroot -p. Then, issue the FLUSH PRIVILEGES; command:

Use the mysql schema by issuing: use mysql;. Then, run the command UPDATE user set Password=PASSWORD(‘yourNewPass’) where User=’root’;

End the commands with FLUSH PRIVILEGES;

Step 4: Shutdown and Restart

To restart the database, you will have to stop it with sudo mysqladmin shutdown. Then, restart it with systemctl start mariadb :

Try your new password out!

Conclusion

Hopefully this has helps you to regain access to your MySQL/MariaDB databases, should you need it. As always, feel free to email us if you have any questions support@automox.com.

About Automox

Facing growing threats and a rapidly expanding attack surface, understaffed and alert-fatigued organizations need more efficient ways to eliminate their exposure to vulnerabilities. Automox is a modern cyber hygiene platform that closes the aperture of attack by more than 80% with just half the effort of traditional solutions.

Cloud-native and globally available, Automox enforces OS & third-party patch management, security configurations, and custom scripting across Windows, Mac, and Linux from a single intuitive console. IT and SecOps can quickly gain control and share visibility of on-prem, remote and virtual endpoints without the need to deploy costly infrastructure.

Experience modern, cloud-native patch management today with a 15-day free trial of Automox and start recapturing more than half the time you're currently spending on managing your attack surface. Automox dramatically reduces corporate risk while raising operational efficiency to deliver best-in-class security outcomes, faster and with fewer resources.

More posts like this:

Linux
# of endpoints

15-day free trial. No credit card required.

By submitting this form you agree to our terms of service.

Already have an account?