Reset MySQL forgotten root Password

MySQL
Step # 1: Stop the MySQL server process. [[email protected] ~]# /etc/init.d/mysqld stopStopping mysqld:                                           [  OK  ]Step # 2: Start the MySQL (mysqld) server/daemon process with the –skip-grant-tables option so that it will not prompt for a password.[[email protected] ~]# mysqld_safe –skip-grant-tables &[1] 12703[[email protected] ~]# 2017-07-16T19:08:25.101474Z mysqld_safe Logging to ‘/var/log/mysqld.log’.2017-07-16T19:08:25.114178Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysqlStep # 3: Connect to the MySQL server as the root user.[[email protected] ~]# mysql -u rootWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 4Server version: 5.7.18 MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners. Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement. mysql>Step # 4: Set a new root password and exitmysql> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> update user set authentication_string=PASSWORD(“New_Password”);Query OK, 2 rows affected, 1 warning (0.00 sec)Rows matched: 2  Changed: 2  Warnings: 1mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)mysql> quitByeStep # 5: Restart the MySQL server and Test[[email protected] ~]# /etc/init.d/mysqld stop2017-07-16T19:28:04.053532Z mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid endedStopping mysqld:                                           [  OK  ][1]+  Done                    mysqld_safe –skip-grant-tables[[email protected] ~]# /etc/init.d/mysqld startStarting mysqld:                                           [  OK  ][[email protected] ~]# mysql -u root -pEnter password:Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 6Server version: 5.7.18 MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners. Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement. mysql>

Leave a Reply

Your email address will not be published.