Difference between revisions of "mysql server root password recovery"

From thelinuxwiki
Jump to: navigation, search
(Created page with "# Stop MySQL # sudo /etc/init.d/mysqld stop # start mysql in Safe mode # mysqld_safe --skip-grant-tables & # Login as root # mysql -uroot # Reset Password # use my...")
 
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
# Stop MySQL
+
Stop MySQL
  
  # sudo /etc/init.d/mysqld stop
+
  # sudo /etc/init.d/mysql stop
  
# start mysql in Safe mode
+
start mysql in Safe mode
  
  
 
  # mysqld_safe --skip-grant-tables &
 
  # mysqld_safe --skip-grant-tables &
  
# Login as root
+
Login as root
  
 
  # mysql -uroot
 
  # mysql -uroot
  
# Reset Password
+
Reset Password
  
  # use mysql;
+
  mysql> use mysql;
 
  mysql> update user set password=PASSWORD("mynewpassword") where User='root';
 
  mysql> update user set password=PASSWORD("mynewpassword") where User='root';
 
  mysql> flush privileges;
 
  mysql> flush privileges;
 
  mysql> quit
 
  mysql> quit
  
# Restart
+
Restart
  
 
  # killall mysqld
 
  # killall mysqld
  # /etc/init.d/mysqld start
+
  # /etc/init.d/mysql start
 +
 
 +
start and stop commands may vary depending on Linux distro
  
 
[[category:mysql]]
 
[[category:mysql]]

Latest revision as of 03:07, 12 July 2016

Stop MySQL

# sudo /etc/init.d/mysql stop

start mysql in Safe mode


# mysqld_safe --skip-grant-tables &

Login as root

# mysql -uroot

Reset Password

mysql> use mysql;
mysql> update user set password=PASSWORD("mynewpassword") where User='root';
mysql> flush privileges;
mysql> quit

Restart

# killall mysqld
# /etc/init.d/mysql start

start and stop commands may vary depending on Linux distro