Multiple Mysql Instances On Single Machine
Multiple Mysql Instances On Single Machine
[email protected]
+92 311 4848475
1. If you have time its better to ameliorate your knowledge in your field.
2. In most of the organizations developers require to have tens of mysql instances so in such case infra team is not
ready to provide single machine for those tens of mysql instances separately also doing so is just waste of
resources.
Lab:
Existing Environment:
#Verifying single instance is running.
#updating the copied my2.cnf file to make it ready for the second instance.
23-Jan-2025
Dost Muhammad Khalil (OCP)
[email protected]
+92 311 4848475
#Checking the directory for the second instance which is currently empty.
#initialization of mysqld which creates the necessary files for mysql second instance
23-Jan-2025
Dost Muhammad Khalil (OCP)
[email protected]
+92 311 4848475
#As this is fresh instance so we will have to cat the error log file to get the temporary created password to connect to
the instance and change the password for root.
#Connecting to second instance and change the temporary password for root user.
#Now its difficult to manually differentiate between the instances while connecting to them and checking to them so
that’s why we will create service for the second instance as well which will allow us to connect, check the status as
like the first one instance for which we use “systemctl status mysqld”
23-Jan-2025
Dost Muhammad Khalil (OCP)
[email protected]
+92 311 4848475
##append the following two lines in mysqld2.service file if already exists comment out them
#mysqld2 can now be used to start,stop and check status for the second instance.
#Now one last thing is to automate the connect with the instances so for this just do the below lines in .bashrc file.
#As can be seen its simple now to connect with the first and the second instance.
23-Jan-2025
Dost Muhammad Khalil (OCP)
[email protected]
+92 311 4848475
23-Jan-2025