Search

Thursday, May 2, 2013

Resetting the MYSQL Root Password

1.
[root@rak3 Mysql Binaries]# ps -ef | grep mysqld
root      7742     1  0 18:31 pts/3    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/rak3.saravanan.com.pid
mysql     7833  7742  0 18:31 pts/3    00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/rak3.saravanan.com.err --pid-file=/var/lib/mysql/rak3.saravanan.com.pid
root      8685  6545  0 18:53 pts/3    00:00:00 grep mysqld


2.
[root@rak3 Mysql Binaries]# mysql -u root -p
Enter password:                                                ----> password is not accepting
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)


3.
[root@rak3 Mysql Binaries]# sudo /etc/init.d/mysql stop
Shutting down MySQL.                                       [  OK  ]


4.
[root@rak3 Mysql Binaries]# mysqld_safe --skip-grant-tables &
[1] 5988
130429 18:58:21 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql


5.
[root@rak3 Mysql Binaries]# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.31 MySQL Community Server (GPL)

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.


6.
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


7.
mysql> update user set password=PASSWORD("mysqlbcp") where User='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0


8.
mysql> flush privileges;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'privilages' at line 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye


9.
[root@rak3 Mysql Binaries]# /etc/init.d/mysql stop
Shutting down MySQL.130429 19:01:58 mysqld_safe mysqld from pid file /var/lib/mysql/rak3.saravanan.com.pid ended
                                                           [  OK  ]
[1]+  Done                    mysqld_safe --skip-grant-table


10.
[root@rak3 Mysql Binaries]# /etc/init.d/mysql start
Starting MySQL..                                           [  OK  ]


11.
[root@rak3 Mysql Binaries]# mysql -u root -p 
Enter password:                                                         -->enter the update password  : mysqlbcp
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.31 MySQL Community Server (GPL)

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>

Steps to change SCAN IP address in 11gR2 RAC

 

SCAN (Single Client Access Name) is a new concept introduced in 11gR2. SCAN helps to eliminate the use of Vitual IP(VIP) for the node failover.
Before 11gR2 we were using VIP, In the Grid Infrastructure when ever new node added or delete, entry of this node need to maintained in tnsnames.ora file accordingly.
But in 11gR2 Oracle created a listener running on top of the node listeners. This listener needs 3 SCAN IP's to be configured on the DNS
And it creates a virtual hostname which can be used as a signle entry in the tnsnames.ora

To Change the SCAN IP  address it must be available and need to changes on the DNS by the network admin. So we have SCAN IP address available.

Steps:

1. To check the current status SCN IP address on  DNS
$nslookup <scan-name>
$nslookup testrac-scan.abc.com
Server:         160.34.11.20
Address:        160.34.11.21#40
Name:   testrac-scan.abc.com
Address: 160.34.11.88
Name:   testrac-scan.abc.com
Address: 160.34.11.89
Name:   testrac-scan.abc.com
Address: 160.34.11.90

2. Check the current status SCAN-VIP in the resource file
# $GRID_HOME/bin/srvctl config scan
SCAN name: testrac-scan, Network: 1/10.101.10.0/255.255.255.0/eth4
SCAN VIP name: scan1, IP: /testrac-scan.abc.com/160.34.11.88
SCAN VIP name: scan2, IP: /testrac-scan.abc.com/160.34.11.89
SCAN VIP name: scan3, IP: /testrac-scan.abc.com/160.34.11.90

3. Request network admin to update NEW SCAN IP address in the DNS server.
Example:
Old SCAN IP:
160.34.11.88
160.34.11.89
160.34.11.90
new SCAN IP:
170.35.12.60
170.35.12.61
170.35.12.62
$nslookup testrac-scan.abc.com
Server:         170.35.12.20
Address:        170.35.12.21#40
Name:   testrac-scan.abc.com
Address: 170.35.12.60
Name:   testrac-scan.abc.com
Address: 170.35.12.61
Name:   testrac-scan.abc.com
Address: 170.35.12.62

4.CRS to update the SCAN VIP resources:
Note: current SCAN-VIP resource should be stopped before modifying the CRS resoruce file.
# $GRID_HOME/bin/srvctl stop scan_listener
# $GRID_HOME/bin/srvctl stop scan
# $GRID_HOME/bin/srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is not running
SCAN VIP scan2 is enabled
SCAN VIP scan2 is not running
SCAN VIP scan3 is enabled
SCAN VIP scan3 is not running
# $GRID_HOME/bin/srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is not running
SCAN Listener LISTENER_SCAN2 is enabled
SCAN listener LISTENER_SCAN2 is not running
SCAN Listener LISTENER_SCAN3 is enabled
SCAN listener LISTENER_SCAN3 is not running
# $GRID_HOME/bin/srvctl modify scan -n testrac-scan.abc.com

5. To verify that the change was successful
# $GRID_HOME/bin/srvctl config scan
SCAN name: sales-scan, Network: 1/1/10.101.10.0/255.255.255.0/eth4
SCAN VIP name: scan1, IP: /testrac-scan.abc.com/170.35.12.60
SCAN VIP name: scan2, IP: /testrac-scan.abc.com/170.35.12.61
SCAN VIP name: scan3, IP: /testrac-scan.abc.com/170.35.12.62

6. Start SCAN and the SCAN listener
# $GRID_HOME/bin/srvctl start scan
# $GRID_HOME/bin/srvctl start scan_listener

Step by Step MYSQL 5.5 Installation

                    [ I have implemented this MYSQL 5.5 installation on OEL 5.5 ]


1.
Download the following Mysql Binaries... and login as root user  in Linux operation system and change the permission and change the ownership of the binaries..

ex:  ( I have done this on one file follow the same steps on all the three files )
#chmod 777 MySQL-client-5.5.31-1.rhel5.x86_64.rpm
#chown  oracle:oinstall MySQL-client-5.5.31-1.rhel5.x86_64.rpm

[root@rak3 Mysql Binaries]# ls -lrt
total 80632
-rwxrwxrwx 1 oracle oinstall 18295684 Apr 29 12:32 MySQL-client-5.5.31-1.rhel5.x86_64.rpm
-rwxrwxrwx 1 oracle oinstall  3887652 Apr 29 12:40 MySQL-devel-5.5.31-1.rhel5.x86_64.rpm
-rwxrwxrwx 1 oracle oinstall 55160490 Apr 29 12:54 MySQL-server-5.5.31-1.rhel5.x86_64.rpm


2.
Install the downloaded Mysql binaries on the Linux operation system as root user.

[root@rak3 Mysql Binaries]# rpm -ivh MySQL-server-5.5.31-1.rhel5.x86_64.rpm MySQL-client-5.5.31-1.rhel5.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [ 50%]
   2:MySQL-server           ########################################### [100%]


3.
PLEASE REMEMBER TO SET  PASSWORD FOR THE MySQL root USER !!!!!

#/usr/bin/mysqladmin -u root password 'mysql'
Starting MySQL..                                           [  OK  ]

Note: my root password for mysql login is : mysqladmin


4.
Alternatively you can run:
(This is optional installation step if you are building production database you can avoid sample database on the mysql database.. for the learning you can keep it..  It ask's for your permission. Read the requirement just type yes/no.. In my case I've printed No for all options :-)


[root@rak3 ~]# /usr/bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] n
 ... skipping.

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] n
 ... skipping.

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] n
 ... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] n
 ... skipping.

Cleaning up...

All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

[root@rak3 ~]#



5.
Starting the Mysql database using the below command.

#sudo /etc/init.d/mysql start

To verify Mysql background running or not (if  mysql started successfully then you can see this BG processor)
[root@rak3 ~]# ps -ef | grep mysqld
root      5391     1  0 13:22 pts/1    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/rak3.saravanan.com.pid
mysql     5485  5391  0 13:22 pts/1    00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/rak3.saravanan.com.err --pid-file=/var/lib/mysql/rak3.saravanan.com.pid
root      5532  7958  0 13:23 pts/1    00:00:00 grep mysqld


6.
To verify the install mysql binaries on the Linux operation system

[root@rak3 ~]# rpm -qa | grep -i mysql
MySQL-server-5.5.31-1.rhel5
MySQL-client-5.5.31-1.rhel5


7.
Installing the remaining mysql binary to the Linux operation system

[root@rak3 Mysql Binaries]# rpm -ivh MySQL-devel-5.5.31-1.rhel5.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MySQL-devel            ########################################### [100%]
[root@rak3 Mysql Binaries]#

To verify the installed version of Mysql  on the Linux operation system.
[root@rak3 Mysql Binaries]# mysql -V
mysql  Ver 14.14 Distrib 5.5.31, for Linux (x86_64) using readline 5.1


8.

Login into Mysql as root user  ( In section 3 we already created password mysqladmin )

[root@rak3 Mysql Binaries]# mysql -u root -p
Enter password:                                                    <-- here you need to enter password

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.31 MySQL Community Server (GPL)

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>