Friday, February 15, 2013

Change Mysql root password on Centos or Redhat RHEL


1. Default mysql password is “null” so we can access to mysql without password
[root@Centos6 ~]# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.66 Source distributionCopyright (c) 2000, 2012, 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>
2. Set root password
[root@Centos6 ~]# mysqladmin -u root password P@ssw0rd
[root@Centos6 ~]#
3. Change root password
[root@Centos6 ~]# mysqladmin -u root -p’P@ssw0rd’ password newP@ssw0rd
[root@Centos6 ~]#
4. Login to mysql with new password
[root@Centos6 ~]# mysql -p
Enter password: newP@ssw0rd
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.1.66 Source distributionCopyright (c) 2000, 2012, 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