Saturday, December 03, 2005

Resetting Root Password for MySql

[root@mybox mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 4.0.15

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
mysql> UPDATE user
-> SET password=password("password")
-> WHERE user="root";
Query OK, 2 rows affected (0.50 sec)
Rows matched: 4 Changed: 2 Warnings: 0

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

mysql> exit;


Now I have reset the root password for MySql to password

Trying with the new password

[root@mybox mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 4.0.15

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

Another Way :

[root@mybox mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 4.0.15

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> SET PASSWORD FOR root@localhost=PASSWORD('pass123');
Query OK, 0 rows affected (0.02 sec)

mysql> quit
Bye

No comments: