Thursday, March 19, 2015

.::: Simple Reset Password root MySQL on Windows, Solaris, Linux, Centos, Redhat, Freebsd, Ubuntu and another :::.

 MySQL (officially pronounced as /maɪ ˌɛskjuːˈɛl/ "My S-Q-L", and unofficially as /maɪ ˈsiːkwəl/ "My Sequel") is an open-source relational database management system (RDBMS); in July 2013, it was the world's second most[a] widely used RDBMS, and the most widely used open-source client–server model RDBMS. It is named after co-founder Michael Widenius's daughter, My. The SQL acronym stands for Structured Query Language. 

 The MySQL development project has made its source code available under the terms of the GNU General Public License, as well as under a variety of proprietary agreements. MySQL was owned and sponsored by a single for-profit firm, the Swedish company MySQL AB, now owned by Oracle Corporation. For proprietary use, several paid editions are available, and offer additional functionality.



A. Forgot your mysql root password. 

1. Linux/Solaris/Unix Platform
Stop MySQL Service

Open terminal 1
# mysqld_safe --skip-grant-tables



Pararel open other terminal

Open Terminal 2

# mysql -u root -p

mysql> UPDATE mysql.user SET Password=PASSWORD('root')WHERE User='root';
mysql> FLUSH PRIVILEGES;

Login after reset password root (for myblog sample using password root )
# mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.5.27 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, 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>


1. Windows Platform


Open Command Prompt 1
stop service mysql
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysqld.exe --skip-grant-tables


Open Command Prompt 2
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\teguh.triharto>mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.27 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, 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> UPDATE mysql.user SET Password=PASSWORD('root')WHERE User='root';
Query OK, 1 row affected (0.12 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.28 sec)

mysql> \q
Bye

C:\Users\teguh.triharto>
C:\Users\teguh.triharto>mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.5.27 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, 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>

B. Forgot other user admin mysql password.
mysql> UPDATE mysql.user SET Password=PASSWORD('password')WHERE User='admin';
mysql> FLUSH PRIVILEGES;


C:\Users\teguh.triharto>mysql -u admin -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.5.27 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, 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>
 


No comments:

Post a Comment

Popular Posts