Difference between revisions of "Resetting MySQL root password"

From Notes_Wiki
m
m
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Resetting mysql root password=
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[Mariadb configuration|MariaDB configuration]] > [[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:
In case we have root privileges on server and want to reset mysql root password then we can use following steps:


#Stop mysql service if it is running.
#Stop mysql service if it is running.
#Use command '<tt>mysqld_safe --skip-grant-tables</tt>' to run mysql without any priviledge information
#:<pre>
#Connect to mysql by simply typing '<tt>mysql</tt>' without any options
#:: service mysqld stop
#Use database mysql using 'use mysql'
#:</pre>
#Change root password or disable it using "update user set password=password('secret') where user='root'" or "update user set password='' where user='root'"
#Use below command to run mysql without any priviledge information
#Stop mysql using command "service mysqld stop"
#:<pre>
#:: mysqld_safe --skip-grant-tables &
#:</pre>
#Connect to mysql by without any options or authentication
#:<pre>
#:: mysql
#:</pre>
#Use database mysql using:
#:<pre>
#:: use mysql
#:</pre>
#Change root password using:
#:<pre>
#:: update user set password=password('secret') where user='root'
#:</pre>
#: or disable it using:
#::<pre>
#::: update user set password='' where user='root'
#::</pre>
#Stop mysql using command:
#:<pre>
#:: service mysqld stop
#:</pre>
#: '''This did not work in stopping mysql.  Had to kill mysqld_safe and later mysql process to stop mysql.'''
#Start mysql again without any password or with the new password set.
#Start mysql again without any password or with the new password set.


Back to [[Mysql configuration]]
 
Refer:
* https://fullstack-tutorials.com/mysql/reset-mysql-root-password-in-centos-7
 
 
 
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[Mariadb configuration|MariaDB configuration]] > [[Resetting MySQL root password]]

Latest revision as of 02:52, 5 March 2022

Home > CentOS > CentOS 6.x > MariaDB configuration > 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
    This did not work in stopping mysql. Had to kill mysqld_safe and later mysql process to stop mysql.
  7. Start mysql again without any password or with the new password set.


Refer:


Home > CentOS > CentOS 6.x > MariaDB configuration > Resetting MySQL root password