Multiple Mysql Instances On Same Machine

                Multiple Mysql Instances On Same Machine

I am using RHEL5.8 64 Bit Machine and Using mysql (mysql-5.0.77-4.el5_6.6)
We Need 2 Instances in Same Machine.

[root@localhost ~]# yum install mysql* -y

[root@localhost ~]# rpm -qa | grep -i mysql
php-mysql-5.1.6-32.el5
perl-DBD-MySQL-3.0007-2.el5
mysql-5.0.77-4.el5_6.6
mysql-server-5.0.77-4.el5_6.6

[root@localhost ~]# /etc/init.d/mysqld restart

[root@localhost ~]# mysqladmin password "Password"

[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.0.77 Source distribution

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

mysql> exit

[root@localhost ~]# netstat  -tulnp | grep mysql
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      8284/mysqld


[root@localhost ~]# cp /etc/init.d/mysqld /etc/init.d/mysqld3307

[root@localhost ~]# ll /etc/init.d/mysqld
-rwxr-xr-x 1 root root 4286 Apr 28  2011 /etc/init.d/mysqld

[root@localhost ~]# ll /etc/init.d/mysqld3307
-rwxr-xr-x 1 root root 4378 Jul 20 12:29 /etc/init.d/mysqld3307

[root@localhost ~]# cp /etc/my.cnf  /etc/my3307.cnf

[root@localhost ~]# vim /etc/my3307.cnf ( change Below lines )
[mysqld]
datadir=/var/lib/mysql3307
socket=/var/lib/mysql3307/mysql3307.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld3307.log
pid-file=/var/run/mysqld3307/mysqld3307.pid

[root@localhost ~]# mkdir /var/run/mysqld3307

[root@localhost ~]# chown mysql.mysql /var/run/mysqld3307/

[root@localhost ~]# chmod  755 /var/run/mysqld3307/

[root@localhost ~]# vim /etc/init.d/mysqld3307 ( Find these line from this file and change accordingly  )
# config: /etc/my.cnf 
TO 
# config: /etc/my3307.cnf

get_mysql_option mysqld datadir "/var/lib/mysql" 
"TO" 
get_mysql_option mysqld3307 datadir "/var/lib/mysql3307"

get_mysql_option mysqld socket "$datadir/mysql.sock" 
"TO" 
get_mysql_option mysqld3307  socket "$datadir/mysql3307.sock"

get_mysql_option mysqld_safe log-error "/var/log/mysqld.log" 
"TO" 
get_mysql_option mysqld3307_safe log-error "/var/log/mysqld3307.log"

get_mysql_option mysqld_safe pid-file "/var/run/mysqld/mysqld.pid" 
"TO"  
get_mysql_option mysqld3307_safe pid-file "/var/run/mysqld3307/mysqld3307.pid"

/usr/bin/mysqld_safe   --datadir="$datadir" --socket="$socketfile" \
"TO" 
/usr/bin/mysqld_safe   --datadir="$datadir" --socket="$socketfile" --port=3307 \

/var/lock/subsys/mysqld 
"TO"
/var/lock/subsys/mysqld3307 ( Change All Peramitrs )

status mysqld 
"TO"

status mysqld3307

FILE SAVE AND QUIT

[root@localhost ~]# /etc/init.d/mysqld3307  restart
Stopping MySQL:                                            [  OK  ]
Starting MySQL:                                            [  OK  ]

[root@localhost ~]# netstat -tulnp | grep mysql
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      17903/mysqld       
tcp        0      0 0.0.0.0:3307                0.0.0.0:*                   LISTEN      2104/mysqld  

[root@localhost ~]# mysqladmin password "raju" --port=3307 --socket=/var/lib/mysql3307/mysql3307.sock

[root@localhost ~]# mysql -u root -p --port=3307 --socket=/var/lib/mysql3307/mysql3307.sock
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.0.77 Source distribution

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

mysql> exit

Comments

Popular posts from this blog

PCS Corosync Pacemaker Cluster Mariadb using NFS

How to install and configure node js and PM2 in rhel7

How to Create or Configure iSCSI Server and Clinet