Mysql Change Root Password

Mysql Change Root Password

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.


TABLE OF CONTENTS


Mysql Change Root Password


Steps to reset a MySQL root password


Talk to AWS Certified Consultant


Patient Management Portal


Why you need Spa and Salon management software?
Let Us Talk About Your AWS Development Requirements

WordPress Table of Contents by Topic

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

Steps to reset a MySQL root password

Use the following steps to reset a MySQL root password by using the command line interface.

  • Step 1: Stop the MySQL service
$ sudo /etc/init.d/mysql stop

step-1

  • Step 2: Run the following command. The ampersand (&) at the end of the command is required.
$ sudo mysqld_safe --skip-grant-tables &

step-2

  • Step 3: Step 3 ( Optional ) In some cases, you’ve to create the /var/run/mysqld first:
$ sudo mkdir -v /var/run/mysqld && sudo chown mysql /var/run/mysqld

step-3

  • Step 4: Connect to MySQL
  • Run the following command:
$ mysql -uroot

step-4

  • Step 5: Set a new MySQL root password
  • Run the following command:
  • Change the database to mysql
mysql> use mysql;

step-5a

  • Replace “mynewpassword”
    • mysql> update user set authentication_string=PASSWORD(“mynewpassword”) where User=’root’;

step-5b

    • mysql> flush privileges;

step-5c

    • mysql> exit
  • Step 6: Stop and start the MySQL service
  • Stop the mysql service
$ sudo /etc/init.d/mysql stop

step-6a

  • Start the mysql service
$ sudo /etc/init.d/mysql start

step-6b

  • Step 7: Log in to the database
  • Test the new password by logging in to the database.
$ mysql -u root -p

step-7a

  • Enter your new password when prompted.

step-7b

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

 

Talk to AWS Certified Consultant

    Spread Love By Sharing:

    Let’s Talk About Your Needed AWS Infrastructure Management Services

    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.

    • Swift Hiring and Onboarding
    • Experienced and Trained AWS Team
    • Quality Consulting and Programming
    Let’s Connect and Discuss Your Project