May 29, 2020 / Nirav Shah
MySQL is a database management system operated under the Open Source software model. It has become a very popular software package for web application software. Like many web services, MySQL has an administrator-level or root password. The root password allows a user to perform all top-level functions in the database.
If you’ve never set a root password on your MySQL database, you should be able to connect to it. However, this is not a good idea as it means anyone can access your database.
If your database already has a root password, but you lost track of it, this guide will help you reset a Mysql Root password on Linux
Use the following steps to reset a MySQL root password by using the command line interface.
$ sudo /etc/init.d/mysql stop

$ sudo mysqld_safe --skip-grant-tables &

$ sudo mkdir -v /var/run/mysqld && sudo chown mysql /var/run/mysqld

$ mysql -uroot

mysql> use mysql;



$ sudo /etc/init.d/mysql stop

$ sudo /etc/init.d/mysql start

$ mysql -u root -p


Also read: How Enable Username & Password Authentication for Linux EC2

Nirav Shah is the Director of Eternal Web Pvt Ltd, an AWS Advanced Consulting Partner and certified Odoo Partner based in the UK. With over a decade of experience in cloud computing, digital transformation, and ERP implementation, Nirav helps enterprises adopt the right technology to solve complex business challenges. He specialises in AWS infrastructure, Odoo ERP, and web development solutions for businesses across the UK and beyond.
Have queries about your project idea or concept? Please drop in your project details to discuss with our AWS Global Cloud Infrastructure service specialists and consultants.