How to reset mysql or Mariadb root password ?

How to reset mysql or Mariadb root password ?

1.  First you need to stop mysql or Mariadb server.

root@localhost:# service mariadb stop   

root@localhost:~#   service mysql stop   

 2. Start the MySQL/MariaDB server without loading the grant tables.

root@localhost:~# mysqld_safe --skip-grant-tables &

           When the --skip-grant-tables option is used, anyone can connect to the database server without a password and with all privileges granted. 

 3. Log in to the Mysql shell

root@localhost:~# mysql -u root. 

 4. Set a new password.

  At the mysql >  prompt, reset the password. To do this, type the following command, replacing "new-password"  with the new root password

UPDATE mysql.user SET Password=PASSWORD('new-password') WHERE User='root';

 5.  At the  mysql>  prompt, type the following commands:



6. Stop the MySQL server using the following command. You will be prompted to enter the new MySQL root password before the MySQL server shuts down:

root@localhost:~# mysqladmin -u root -p shutdown

 7 Start the mysql/mariadb server normally

root@localhost:~# service mariadb start

5 (1)
Article Rating (1 Votes)
Rate this article
    Attached Files
    There are no attachments for this article.
    Related Articles RSS Feed
    Do i need to install an agent on every machine or instance that I need to manage in Ezeelogin?
    Viewed 1442 times since Mon, Aug 21, 2017
    Enable SSH Key based authentication and Disable Password Authentication in ssh
    Viewed 150 times since Tue, Apr 21, 2020
    What is ezeelogin?
    Viewed 1438 times since Mon, Aug 21, 2017
    Trial License Vs Paid License
    Viewed 2482 times since Wed, Jun 14, 2017
    Is it a hosted solution?
    Viewed 1477 times since Mon, Aug 21, 2017
    Will i be locked out if i loose connectivity to the license server or if the Ezeelogin license servers goes down?
    Viewed 2465 times since Mon, Aug 21, 2017
    MariaDB Connector Vulnerability CVE-2020-13249
    Viewed 29 times since Wed, Jun 17, 2020
    Will i be locked out of my servers if my ezeelogin hosted server goes down ?
    Viewed 2590 times since Mon, Aug 21, 2017
    How to set user password lifetime for expiry
    Viewed 127 times since Wed, Apr 15, 2020
    Connect jumpserver using putty
    Viewed 689 times since Tue, Apr 2, 2019