Cool Dba

  • Home
  • Sql tricks
  • Security
  • Maintainance
  • Backups
  • Recovery
  • Replication
  • Installation
  • Linux

Thursday, May 26, 2016

Running multiple mysql instance on single server(Centos&Red Hat)

 Anil Joshi     12:17 AM     Database Maintainance, Installation     No comments   


 Follow Below Steps:-
Step (1): Create a new MySQL data directory.
mkdir -p /var/lib/mysql2
Step 2:  Give permission and ownership .Now we are taking ownership and permission reference from original /var/lib/mysql data directory

chmod --reference /var/lib/mysql /var/lib/mysql2
chown --reference /var/lib/mysql /var/lib/mysql2
Step 3: Now create a new my1.cnf file and paste the below given contents. We will run the new mysql instance in port no. 3307.
Copy the my.cnf file and make it blank
cp -p /etc/my.cnf /etc/my1.cnf
Now edit with vi editor.
vi /etc/my1.cnf
Edit in [mysqld] and [mysqld_safe] section.
[mysqld]
datadir=/var/lib/mysql2
socket=/var/lib/mysql/mysql2.sock
port=3307

[mysqld_safe]
log-error=/var/log/mysqld2.log
pid-file=/var/run/mysqld/mysqld2.pid
Step 4: Now install the database in the new mysql data directory
mysql_install_db --user=mysql --datadir=/var/lib/mysql2

Step 5: Now the new instance is ready.Now start and stop with the below commands
To start new mysql instance,use below given command
mysqld_safe --defaults-file=/etc/my1.cnf &
Now check the port no. 3337 is listening or not
netstat -tanp |grep 3307
To connect new mysql instance
Syntax: mysql -u username -p -h 127.0.0.1 -P port-no

Now set root password 
mysql > use mysql;
mysql > update user set password=PASSWORD("password") where User='root';
mysql > flush privileges;
mysql > exit
To stop new mysql instance use below given command
mysqladmin -S /var/lib/mysql/mysql2.sock shutdown -p

  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook
Newer Post Older Post Home

0 comments:

Post a Comment

Deals on Amazon

Mobiles on Amazon

About Me

My photo
Anil Joshi
New Delhi, Delhi, India
I am a simple man with little knowledge of computer software and Tehnology.
View my complete profile

Popular Posts

  • SELinux mechanism in linux environment.
    Security-Enhanced Linux (SELinux) is a mandatory access control (MAC) security mechanism implemented in the kernel. SELinux was first ...
  • Finding and preventing ddos attack on Linux Server
    A distributed denial-of-service (DDoS) attack occurs when multiple systems flood the bandwidth or resources of a targeted system, usual...
  • Master-Slave Replication without downtime
    First, we configure master’s   /etc/mysql/my.cnf   by including these lines in the [mysqld] section: server - id = 1 bin...
  • Mysql Security
    Improved  MySQL Database Se curity 1. Secure your server Many known attacks are possible only once physical access to a machi...
  • Check and Repair Mysql Tables
      Check a Specific Table in a Database If your application throws an error message saying that a specific table is corrupted, exe...
  • Filter Replication Variables
    Filtering can be done on the Master or on the Slave. Filtering on the Slave is normally preferred as in this case you get full binary lo...
  • Complete uninstallation of Mysql Server on centos
    Step 1: Check list the mysql rpm which is installed on server rpm -qa | grep mysql or yum list installed | grep mysql Step 2 : Re...
  • Tracing the execution of processes using strace
    Strace is quite simply a tool that traces the execution of system calls. It can trace the execution of a binary from start to end, and ou...
  • Mysql Installation using rpm package
        1.Download the required rpm filess MySQL-client-community-5.1.25-0.rhel5.i386.rpm MySQL-server-community-5.1.25-0.rhel5.i386....
  • MySQL Restart Failed
           MySQL Restart Failed :   The Server Quit Without Updating PID File [root@server: ~ ] $ service mysqld start Starti...
Best Shoes on amazon

Categories

  • Backups
  • Database Maintainance
  • Installation
  • Linux
  • Mysql
  • Recovery
  • Replication
  • Scripts
  • Security
  • SELinux
  • sql tricks
  • Strace

Pages

  • Home

Blog Archive

  • ▼  2016 (19)
    • ►  June (1)
    • ▼  May (18)
      • Finding and preventing ddos attack on Linux Server
      • Tracing the execution of processes using strace
      • SELinux mechanism in linux environment.
      • Simple bash script's for managing mysql
      • Running multiple mysql instance on single server(C...
      • Mysql Installation using rpm package
      • Check and Repair Mysql Tables
      • Dual Master Replication(Master-Master)
      • Filter Replication Variables
      • Master-Slave Replication without downtime
      • How to Export and Import files in Mysql
      • Recovering InnoDB MySQL Tables Data from ibdata ...
      • Check Database Size,Compare tables & column Differ...
      • Store Procedure & Views Backups
      • Mysql Security
      • MySQL Restart Failed
      • Running select statement inside an update query
      • Mass Killing Mysql Process

Sample Text

Copyright © Cool Dba | Powered by Blogger
Design by Hardeep Asrani | Blogger Theme by NewBloggerThemes.com | Distributed By Gooyaabi Templates