SHARE

Step 1:
Login VPS or dedicated server using SSH.

Step 2:
Open SSH console.

Step 3:
Use following commands:

service mysqld stop

mysqld_safe –skip-grant-tables &
mysql -u root

mysql>
mysql> use mysql;
mysql> UPDATE user SET Password = PASSWORD (‘yournewpassword’) WHERE User=’root’;
mysql> FLUSH PRIVILEGES;
mysql> quit;

service mysqld start

[root@localhost ~]# service mysqld stop
Stopping MySQL: [ OK ]
[root@localhost ~]# mysqld_safe --skip-grant-tables &
[1] 18171
[root@localhost ~]# Starting mysqld daemon with databases from /var/lib/mysql
mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.0.95 Source distribution

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> 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 (‘yournewpassword’) WHERE User=’root’
;
Query OK, 3 rows affected (0.28 sec)
Rows matched: 3 Changed: 3 Warnings: 0

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

mysql> quit;
Bye
[root@localhost ~]# service mysqld start
Starting MySQL: [ OK ]
[root@localhost ~]#

Similarly, you can change password of other users.

1 COMMENT