Resetting MySQL root password

From Notes_Wiki
Revision as of 05:06, 25 May 2021 by Saurabh (talk | contribs)

<yambe:breadcrumb self="Resetting MySQL root password">Mariadb configuration | Mariadb configuration</yambe:breadcrumb>

Resetting mysql root password

In case we have root privileges on server and want to reset mysql root password then we can use following steps:

  1. Stop mysql service if it is running.
    service mysqld stop
  2. Use below command to run mysql without any priviledge information
    mysqld_safe --skip-grant-tables
  3. Connect to mysql by without any options or authentication
    mysql
  4. Use database mysql using:
    use mysql
  5. Change root password using:
    update user set password=password('secret') where user='root'
    or disable it using:
    update user set password='' where user='root'
  6. Stop mysql using command:
    service mysqld stop
  7. Start mysql again without any password or with the new password set.



<yambe:breadcrumb self="Resetting MySQL root password">Mariadb configuration | Mariadb configuration</yambe:breadcrumb>