Thursday, 12 April 2012

how to change mysql password

[root@station1 ~]# service mysqld stop
Stopping mysqld:                                           [  OK  ]
[root@station1 ~]# mysqld_safe --skip-grant-tables --skip-networking &
[1] 20120
[root@station1 ~]# 120315 12:05:24 mysqld_safe Logging to '/var/log/mysqld.log'.
120315 12:05:24 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

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

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

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("redhat") where user="root";
Query OK, 0 rows affected (0.00 sec)
Rows matched: 3  Changed: 0  Warnings: 0

mysql> exit
Bye
[root@station1 ~]# service mysqld restart
120315 12:06:25 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
[1]+  Done                    mysqld_safe --skip-grant-tables --skip-networking
[root@station1 ~]# mysql -u root -predhat
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.52 Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

No comments:

Post a Comment