Showing posts with label Steps to reset mysql root password.. Show all posts
Showing posts with label Steps to reset mysql root password.. Show all posts

Saturday, October 5, 2013

Reset Mysql root password

                                                               
                                                                   
Reset root password in Mysql

Method 1:                                          

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set password=password('') where user='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)


[root@test ~]# mysqladmin -u root -p'global!23' password 'linklinux'

[root@test ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 5.1.69 Source distribution

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

[root@gai-1347 ~]# mysqladmin -u root -p'linklinux' password ''

Empty password


Method 2:

Stop mysql

[root@test ~]# mysqld_safe --skip-grant-tables &
[1] 8747                                          
130810 11:38:36 mysqld_safe Logging to '/var/log/mysqld.log'.
130810 11:38:36 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

[root@test ~]# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1                          
Server version: 5.1.69 Source distribution            

Copyright (c) 2000, 2013, 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> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set password=password('linklinux') where user='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> \q
Bye