What's new
BAJUBESI.ORG

Welcome to bajubesi.org, become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Help me install multiple version of mysql on Ubuntu 24.04

Belon

Root Administrator
Staff member
Joined
Dec 1, 2024
Messages
26
Reaction score
2
Points
8
Location
Malaysia
Website
bajubesi.com.my
hye can anyone help me install multiple mysql version in my server? i have multiple CMS that use different version of mysql, can this be done in one single server? please guide me on how do install it correctly.
 
can u help me about this? can u guide me?

Yes, you can install multiple MySQL versions on your Ubuntu Server using apt-get. Here's a step by step guide on how to do that:

1. First of all, update the package list to get information on the newest versions available for upgrade:
Bash:
sudo apt update
2. Install MySQL 5.6 with this command (replace x.x.xx-debug with your specific version number):
Bash:
sudo apt install mysql-server-5.6
3. After installation, you can start the service and check its status:
Bash:
sudo systemctl start mysql
sudo systemctl status mysql
4. To ensure that MySQL will start after a reboot, enable it with this command:
Bash:
sudo systemctl enable mysql
5. Now install another version of MySQL (7.3 as an example). Use the following command (replace x.x.xx-debug with your specific version number):
Bash:
sudo apt install mysql-server-7.3
6. Enable and start this newly installed MySQL Server:
Code:
bash<|begin▁of▁sentence|>
sudo systemctl enable mysql@7.3
sudo systemctl start mysql@7.3
7. To check the status of the two versions you have installed, use these commands:
Bash:
systemctl status mysql | grep 'mysql@5.6'
systemctl status mysql | grep 'mysql@7.3'
Remember to replace x.x.xx-debug with your specific version number in all above commands.

Please note that if you have multiple versions installed, each will bind to a different port (MySQL 5.6 on port 3306 and MySQL 7.3 on port 3307 for example). You would need to configure the CMSs accordingly. Also, make sure your firewall is configured correctly if you are planning to use remote connections to these databases from outside of localhost.

In case you have multiple versions installed at once, you can select which version MySQL should run by using its --defaults-file parameter. But in general we advise against running different major versions on the same server, as this could cause compatibility issues:

Bash:
sudo mysql --version5.6-debug --user=root

Replace version5.6-debug with your specific version number. In case you plan to use MySQL 7.3, replace it there too. Please ensure that the CMSs are updated as well so they can communicate properly with multiple versions of MySQL installed on server simultaneously.
 
Yes, you can install multiple MySQL versions on your Ubuntu Server using apt-get. Here's a step by step guide on how to do that:

1. First of all, update the package list to get information on the newest versions available for upgrade:
Bash:
sudo apt update
2. Install MySQL 5.6 with this command (replace x.x.xx-debug with your specific version number):
Bash:
sudo apt install mysql-server-5.6
3. After installation, you can start the service and check its status:
Bash:
sudo systemctl start mysql
sudo systemctl status mysql
4. To ensure that MySQL will start after a reboot, enable it with this command:
Bash:
sudo systemctl enable mysql
5. Now install another version of MySQL (7.3 as an example). Use the following command (replace x.x.xx-debug with your specific version number):
Bash:
sudo apt install mysql-server-7.3
6. Enable and start this newly installed MySQL Server:
Code:
bash<|begin▁of▁sentence|>
sudo systemctl enable mysql@7.3
sudo systemctl start mysql@7.3
7. To check the status of the two versions you have installed, use these commands:
Bash:
systemctl status mysql | grep 'mysql@5.6'
systemctl status mysql | grep 'mysql@7.3'
Remember to replace x.x.xx-debug with your specific version number in all above commands.

Please note that if you have multiple versions installed, each will bind to a different port (MySQL 5.6 on port 3306 and MySQL 7.3 on port 3307 for example). You would need to configure the CMSs accordingly. Also, make sure your firewall is configured correctly if you are planning to use remote connections to these databases from outside of localhost.

In case you have multiple versions installed at once, you can select which version MySQL should run by using its --defaults-file parameter. But in general we advise against running different major versions on the same server, as this could cause compatibility issues:

Bash:
sudo mysql --version5.6-debug --user=root

Replace version5.6-debug with your specific version number. In case you plan to use MySQL 7.3, replace it there too. Please ensure that the CMSs are updated as well so they can communicate properly with multiple versions of MySQL installed on server simultaneously.
if i have existing latest mysql install already in the same server is it safe to run this command? will it delete and mess up with my current existing database? how do i safely install other version of mysql if my situation like this ?
 
if i have existing latest mysql install already in the same server is it safe to run this command? w...

When you use sudo apt install, Ubuntu uses dpkg package management system. For MySQL installed through that method, the information about its installation is stored in /var/lib/mysql directory by default.

During a new installation, it's generally not recommended to overwrite an existing installation unless you have made a backup or are aware of any potential issues with the current setup and understand what changes might be needed for your CMSs after installing another version of MySQL server. This is due to possible dependencies that may get broken during this operation.

Here's how to install multiple versions without messing up:
1. Make sure you have a backup of your databases.
2. Choose a unique directory name for each installation, like /usr/local/mysql56 and /usr/local/mysql73 etc.
3. Install the MySQL version in its designated directory using --prefix option to specify the path:
sudo apt install mysql-server-5.6 --prefix=/usr/local/mysql56
sudo apt install mysql-server-7.3 --prefix=/usr/local/mysql73
4. The data files will be in /usr/local/mysql56, /usr/local/mysql73 etc., not the default /var/lib/mysql.
5. You can start each server with: sudo /usr/local/mysql56/bin/mysqld_safe & for 5.6 and similar command for 7.3. Remember to replace version numbers appropriately in commands.
6. Make sure you have the necessary firewall rules set up, if needed.

Remember that running multiple MySQL versions on a single server is not recommended due to potential conflicts and issues with data integrity. It's generally better to use containers or virtualization (like Docker) for this purpose instead of installing multiple MySQL servers directly on one physical machine. This way, each version will be isolated from the others and should provide better stability and security in most cases.
 
When you use sudo apt install, Ubuntu uses dpkg package management system. For MySQL installed through that method, the information about its installation is stored in /var/lib/mysql directory by default.

During a new installation, it's generally not recommended to overwrite an existing installation unless you have made a backup or are aware of any potential issues with the current setup and understand what changes might be needed for your CMSs after installing another version of MySQL server. This is due to possible dependencies that may get broken during this operation.

Here's how to install multiple versions without messing up:
1. Make sure you have a backup of your databases.
2. Choose a unique directory name for each installation, like /usr/local/mysql56 and /usr/local/mysql73 etc.
3. Install the MySQL version in its designated directory using --prefix option to specify the path:
sudo apt install mysql-server-5.6 --prefix=/usr/local/mysql56
sudo apt install mysql-server-7.3 --prefix=/usr/local/mysql73
4. The data files will be in /usr/local/mysql56, /usr/local/mysql73 etc., not the default /var/lib/mysql.
5. You can start each server with: sudo /usr/local/mysql56/bin/mysqld_safe & for 5.6 and similar command for 7.3. Remember to replace version numbers appropriately in commands.
6. Make sure you have the necessary firewall rules set up, if needed.

Remember that running multiple MySQL versions on a single server is not recommended due to potential conflicts and issues with data integrity. It's generally better to use containers or virtualization (like Docker) for this purpose instead of installing multiple MySQL servers directly on one physical machine. This way, each version will be isolated from the others and should provide better stability and security in most cases.
how do i do that? how can i use docker to install different version of mysql? and how can i setup example vbulletin when the mysql is using docker? i have docker and portainer install in my server, can u guide me?
 
how do i do that? how can i use docker to install different version of mysql? and how can i setup ex...

Sure, you can run multiple MySQL containers with different versions using Docker. Here's a step-by-step guide on how to do that:

1. Pull the desired MySQL version from DockerHub:
Bash:
docker pull mysql:5.7
docker pull mysql:8.0
2. Run a container with the specific version and set your password, environment variables, ports etc.:
For 5.7:
Bash:
docker run --name some-mysql -p3306:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:5.7
And for 8.0:
Bash:
docker run --name other-mysql -p3307:3306 -e MYSQL_ROOT_PASSWORD=my-other-secret-pw -d mysql:8.0
Replace some-mysql, other-mysql and the passwords with your own identifiers and secure passwords.

3. Now you have two MySQL containers running different versions on your server. You can connect to them using any MySQL client (like mysql command line tool or phpMyAdmin), just use the IP address of your Docker host where these containers are running as the host name, and the exposed port number from docker run command in step 2.

As for setting up vBulletin with this setup, you'll need to create a new database for it within one of the MySQL containers that has been set up (replace my-secret-pw or my-other-secret-pw as per your Docker run command)
Bash:
docker exec -it some-mysql mysql -uroot -pmy-secret-pw
CREATE DATABASE vb_database;
EXIT;
Replace 'some-mysql' with the name of your MySQL container, and replace my-secret-pw with your root password.

Then in vBulletin setup process you would select "Custom" for Database type, put IP address of Docker host where MySQL is running (If it's remote - then that IP), the port number as per docker run command (3306 or 3307) and fill in your database details.
 
Sure, you can run multiple MySQL containers with different versions using Docker. Here's a step-by-step guide on how to do that:

1. Pull the desired MySQL version from DockerHub:
Bash:
docker pull mysql:5.7
docker pull mysql:8.0
2. Run a container with the specific version and set your password, environment variables, ports etc.:
For 5.7:
Bash:
docker run --name some-mysql -p3306:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:5.7
And for 8.0:
Bash:
docker run --name other-mysql -p3307:3306 -e MYSQL_ROOT_PASSWORD=my-other-secret-pw -d mysql:8.0
Replace some-mysql, other-mysql and the passwords with your own identifiers and secure passwords.

3. Now you have two MySQL containers running different versions on your server. You can connect to them using any MySQL client (like mysql command line tool or phpMyAdmin), just use the IP address of your Docker host where these containers are running as the host name, and the exposed port number from docker run command in step 2.

As for setting up vBulletin with this setup, you'll need to create a new database for it within one of the MySQL containers that has been set up (replace my-secret-pw or my-other-secret-pw as per your Docker run command)
Bash:
docker exec -it some-mysql mysql -uroot -pmy-secret-pw
CREATE DATABASE vb_database;
EXIT;
Replace 'some-mysql' with the name of your MySQL container, and replace my-secret-pw with your root password.

Then in vBulletin setup process you would select "Custom" for Database type, put IP address of Docker host where MySQL is running (If it's remote - then that IP), the port number as per docker run command (3306 or 3307) and fill in your database details.
do i need root access to perform all this? i have root access and should i use root to set this up?
 
do i need root access to perform all this? i have root access and should i use root to set this up?

No, you don't necessarily require root access for all these operations. Docker provides its own permissions system to control access to resources like networking, storage, etc., which can be managed with groups on Linux systems.

In general, it is a good practice to not run containers as root unless absolutely necessary (for example, if the container needs to bind to port 80 or 443), because running processes in containers are isolated from the host system by default and have their own set of permissions. This way, an attacker can only affect the process inside the container and not your entire server.

So when you run a Docker command with sudo (or as root directly on some Linux distributions), it's because you want to give more privileges than normal users usually have.

However, for running MySQL in Docker, you typically don't need superuser access if you follow best practices:
1. Use a non-root user when running the container. For example: docker run --name some-mysql -p3306:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:5.7 (Replace with your own password)
2. The MySQL process itself runs as the root user inside the container, but it can be configured to run as a different non-root user through environment variables or configuration files.
3. You should not map port 3306 on the Docker host to any other container unless you really know what you're doing. It is generally not recommended to expose MySQL directly from a running container to the internet world without some sort of security measure in place, like using SSL/TLS and perhaps even a username/password for additional protection.
4. When setting up databases within Docker, it is usually best practice to use non-root users with limited permissions on each database. This way, even if your MySQL server gets compromised, an attacker cannot do anything bad by default.

So while you don't need root access in general from the host system, you may still want a user account that can be used for these operations on the Docker host system to ensure isolation and security.
 
Back
Top