How to Reset mysql root password in Mysql and Mariadb

Database reset mariadb root password reset mysql root password 557 times1 answer1 follower
0
Mel Khamlichi 103 Rep. Avishek Kumar edited question

I am running  Debian 8.  Is there any differences between resetting mysql password in Mariadb-server and Mysql-server.

What are the commands needed for every tool  ?

♥ Spread the love ♥
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
0
Avishek Kumar 449 Rep. Avishek Kumar edited answer

To reset MySQL and/or MariaDB root password, you may proceed as below. Remember MariaDB is a community developed fork of MySQL and you can reset root password of either Database server, as described below.

  1. Stop MySQL
  2. # systemctl stop mysql
    # /etc/init.d/mysql stop
    
  3. Kill all MySQL signal process processes that may be running
  4. # pkill -9 mysql
  5. Run MySQL in safe mode and without a password
  6. # mysqld_safe --skip-grant-tables &
  7. Connect to MySQL
  8. # mysql -u root
    Sample Output
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 1
    Server version: 5.6.30-1 (Debian)
    Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    mysql> 
    
  9. Set new MySQL password. Replace mynewpassword with your password.
  10. mysql> update mysql.user set password=PASSWORD("mynewpassword") where User='root';
  11. Clean Internal Cache of MySQL
  12. mysql> flush privileges;
  13. Exit/Quit MySQL
  14. mysql> exit
    mysql> quit
    
  15. Restart MySQL server
  16. # systemctl restart mysql
    # /etc/init.d/mysql restart
    

    You should now be able to login to MySQL/MariDB with the new password.

    ♥ Spread the love ♥
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
×

Login