Multiple Mysql version on the same server is possible, but it requires some extra configuration.
One way to achieve this is by using containers or virtual machines to isolate each MySQL installation. For example, you could use Docker containers or virtual machines to run each version of MySQL.
Another way is to install each version of MySQL in a separate directory and use different ports for each MySQL installation. You would also need to specify a different configuration file for each installation, which would include the appropriate port number.
To install multiple versions of MySQL on the same server, follow these steps:
Install default server Percona-8.0
1 | sudo yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm | |
2 | percona-release setup ps80 yum install percona-server-server percona-server-devel.x86_64 |
|
3 | service mysqld restart | |
4 | cat /var/log/mysqld.log |grep password | |
5 | ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘MyNewPass’; | You must reset your password using ALTER USER statement before executing any statement. |
TO resolve ERROR 1819 (HY000): Your password does not satisfy the current policy requirements 1st set the password as per policy like ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘Nitwings@111181_Pass’; then fire”SET GLOBAL validate_password.policy = LOW;” or step 6 & 7 |
||
6 | mysql> SHOW VARIABLES LIKE ‘validate_password%’; +————————————–+——–+ | Variable_name | Value | +————————————–+——–+ | validate_password.check_user_name | ON | | validate_password.dictionary_file | | | validate_password.length | 8 | | validate_password.mixed_case_count | 1 | | validate_password.number_count | 1 | | validate_password.policy | MEDIUM | | validate_password.special_char_count | 1 | +————————————–+——–+ 7 rows in set (0.01 sec) |
TO resolve ERROR 1819 (HY000): Your password does not satisfy the current policy requirements 1st set password as per policy like ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘Nitwings@111181_Pass’; and make necessary changes as per step 7 |
7 | SET GLOBAL validate_password.check_user_name = No; SET GLOBAL validate_password.dictionary_file = ”; SET GLOBAL validate_password.length = 0; SET GLOBAL validate_password.mixed_case_count = 0; SET GLOBAL validate_password.number_count = 0; SET GLOBAL validate_password.policy = LOW; SET GLOBAL validate_password.special_char_count = 0;ORUNINSTALL PLUGIN validate_password; UPDATE mysql.user SET Password=PASSWORD(‘your-password’) WHERE User=’root’; |
set password policy. also, you can uninstall the password PLUGIN.
the password plugin name is validate_password but some versions of MySQL have “validate.password”
|
8 | ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘your_password’;
OR UPDATE user SET password=PASSWORD(‘your_password’) WHERE user=’root’; |
set your password |
9 | mysql_secure_installation | run it to secure your Mysql server |
10 | mysql -uroot -p | Percona-8.0 ready to use |
/etc/my.cnf for Percona-8.0 |
Install 2nd server Percona-5.7:-
1 | Percona-Server-5.7.23-23-Linux.x86_64.ssl101.tar.gz | => Go to https://www.percona.com/software/mysql-database/percona-server. => Select Percona Server 5.7. =>Select Product Version ‘PERCONA-SERVER-5.7.23-23’ =>Select Platform ‘LINUX – GENERIC’Note:- chose file as per your OS. => ssl100 – for Debian prior to 9 and Ubuntu prior to 14.04. => ssl101 – for CentOS 6 and CentOS 7. => ssl102 – for Debian 9 and Ubuntu versions starting from 14.04. => ssl1:111 – for CentOS 8 and RedHat 8. => Download it using wget command. |
2 | tar -zxvf Percona-Server-5.7.23-23-Linux.x86_64.ssl101.tar.gz | extract downloaded files |
3 | mkdir /home1/replication/
mv mysql-5.1.73-linux-x86_64-glibc23 /home1/replication/Mysql-204 |
create a base directory ‘Mysql-204’ for the MySQL environment.
|
4 | mkdir /home1/replication/Mysql-204/etc mkdir /home1/replication/Mysql-204/pid touch /home1/replication/Mysql-204/etc/my.cnf |
create my.cnf as per the below example. |
5 | chown mysql:mysql /home1/replication/Mysql-204/ -R | change ownership of the directory |
6 | cd /home1/replication/Mysql-204/
./bin/mysql_install_db –datadir=/home1/replication/Mysql-204/ –datadir=/home1/replication/Mysql-204/data/ –user=mysql |
initialize data directory to create MySQL database. |
7 | /home1/replication/Mysql-204/bin/mysqld_safe –defaults-file=/home1/replication/Mysql-204/etc/my.cnf &
mysql -uroot -p –socket=/home1/replication/Mysql-204/data/mysql.sock –port=3308 |
start MySQL service and log in to MySQL server. |
8 | cat /home1/replication/Mysql-204/mysqld.err |grep pass
or cat /root/.mysql_secret |
find out the password in a log file. |
9 | ./bin/mysqld –defaults-file=/home1/replication/Mysql-204/etc/my.cnf –skip-grant-tables & | if the password is not present in the log file then stop the MySQL service (init file present at step 11) and start with –skip-grant-tables to reset the password. |
10 | flush privileges; ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘your-password’; UPDATE user SET password=PASSWORD(‘your-password’) WHERE user=’root’; flush privileges; |
reset MySQL root password. |
11 |
#! /bin/sh test -f /home1/replication/Mysql-204/bin/mysqld_safe || exit 0 case “$1” in start) echo –n “Starting mysql204: mysql204” cd /home1/replication/Mysql-204 ./bin/mysqld_safe –defaults-file=/home1/replication/Mysql-204/etc/my.cnf & echo “.” ;; stop) echo –n “Stopping mysql204: mysql204” /home1/replication/Mysql-204/bin/mysqladmin –socket=/home1/replication/Mysql-204/data/mysql.sock –port=3307 -u root -p shutdown kill `cat /home1/replication/Mysql-204/pid/mysqld.pid` echo “.” ;; restart) echo –n “Stopping mysql204: mysql204” /home1/replication/Mysql-204/bin/mysqladmin –socket=/home1/replication/Mysql-204/data/mysql.sock –port=3307 -u root -p shutdown kill `cat /home1/replication/Mysql-204/pid/mysqld.pid` echo “.” echo –n “Starting mysql204: mysql204” cd /home1/replication/Mysql-204 ./bin/mysqld_safe –defaults-file=/home1/replication/Mysql-204/etc/my.cnf & echo “.” ;; *) echo “Usage: /etc/init.d/sshd start|stop|restart” exit 1 ;; esac |
init script for restart. |
vi /home1/replication/Mysql-204/etc/my.cnf |
[client] port = 3308 [mysqld] bind-address=0.0.0.0 #skip-grant-tables #skip-networking user=mysql old_passwords=0 expire_logs_days = 30 max_binlog_size = 100M port = 3308 datadir=/home1/replication/Mysql-204/data/ pid-file = /home1/replication/Mysql-204/pid/mysqld_3308.pid #log = /home1/replication/Mysql-204/data/mysql_general.log socket = /home1/replication/Mysql-204/data/mysql.sock #skip-locking skip-external-locking group_concat_max_len=20480 #log general_log ####################### max_allowed_packet = 32M sort_buffer_size = 120M read_buffer_size = 120M read_rnd_buffer_size = 640M myisam_sort_buffer_size = 120M tmp_table_size = 256M query_cache_size = 320M max_connections = 100 max_user_connections = 100 max_connect_errors = 99999999 interactive_timeout=280 wait_timeout=280 skip-name-resolve slave-skip-errors = 1062,1053 ######################## innodb_buffer_pool_size = 200M innodb_log_buffer_size = 32M innodb_flush_log_at_trx_commit = 0 innodb_lock_wait_timeout = 256 innodb_flush_method = O_DIRECT innodb_thread_concurrency = 40 innodb_open_files = 2000 innodb_file_per_table log_bin_trust_function_creators = 1############ Replication ##################### server-id=153 log-bin = /home1/replication/Mysql-204/master-bin.log log-bin-index = /home1/replication/Mysql-204/master-log-bin.index show-slave-auth-info replicate-same-server-id=0 relay-log = /home1/replication/Mysql-204/slave-relay.log relay-log-index = /home1/replication/Mysql-204/slave-relay-log.index log-slave-updates log_output=FILE slow_query_log=1 slow_query_log_file=/home1/replication/Mysql-204/slow_queries.log long_query_time=3 log-slow-admin-statements ######################## [mysqldump] quick max_allowed_packet = 32M [mysql] no-auto-rehash [isamchk] key_buffer = 256M sort_buffer_size = 256M read_buffer = 20M write_buffer = 20M [myisamchk] key_buffer = 1024M sort_buffer_size = 512M read_buffer = 64M write_buffer = 64M[mysqld_safe] log-error=/home1/replication/Mysql-204/mysqld.err pid-file= /home1/replication/Mysql-204/pid/mysqld.pid |
Install 3rd server Mysql-5.1:-
1 | mysql-5.1.73-linux-x86_64-glibc23.tar.gz | => Go to https://downloads.mysql.com/archives/community/?version=5.1.23
=> Product Version:”5.1.23″ |
2 | tar -zxvf mysql-5.1.73-linux-x86_64-glibc23.tar.gz
mkdir /home1/replication/ |
extract downloaded files create a base directory ‘Mysql-187’ for the MySQL environment. |
3 | mkdir /home1/replication/Mysql-187/etc | create an etc directory for ‘my.cnf’ file |
4 | touch /home1/replication/Mysql-204/etc/my.cnf | |
5 | chown mysql:mysql /home1/replication/Mysql-187/ -R | change ownership of the directory with MySQL user and MySQL group. |
6 | cd /home1/replication/Mysql-187/ ./scripts/mysql_install_db –initialize –user=mysql –defaults-file=/home1/replication/Mysql-187/etc/my.cnf |
initialize the data directory to create the MySQL database. |
7 | /home1/replication/Mysql-187/bin/mysqld_safe –defaults-file=/home1/replication/Mysql-187/etc/my.cnf & | start mysql server |
8 | /home1/replication/Mysql-187/bin/mysqladmin –socket=/home1/replication/Mysql-187/data/mysql.sock –port=3307 -u root password ‘your-password’ | change the root password using mysqladmin command. The default password is empty. |
9 | /home1/replication/Mysql-187/bin/mysql -uroot -p –socket=/home1/replication/Mysql-187/data/mysql.sock –port=3307 | login MySQL server |
10 | case “$1” in start) echo –n “Starting mysql187: mysql187” cd /home1/replication/Mysql-187 ./bin/mysqld_safe –defaults-file=/home1/replication/Mysql-187/etc/my.cnf & echo “.” ;; stop) echo –n “Stopping mysql187: mysql187” /home1/replication/Mysql-187/bin/mysqladmin –socket=/home1/replication/Mysql-187/data/mysql.sock –port=3307 -u root -p shutdown kill `cat /home1/replication/Mysql-187/mysqld.pid` echo “.” ;; restart) echo –n “Stopping mysql187: mysql187” /home1/replication/Mysql-187/bin/mysqladmin –socket=/home1/replication/Mysql-187/data/mysql.sock –port=3307 -u root -p shutdown kill `cat /home1/replication/Mysql-187/mysqld.pid` echo “.” echo –n “Starting mysql187: mysql187” cd /home1/replication/Mysql-187 ./bin/mysqld_safe –defaults-file=/home1/replication/Mysql-187/etc/my.cnf & echo “.” ;; *) echo “Usage: /etc/init.d/sshd start|stop|restart” exit 1 ;; esac |
init script the server to stop-start MySQL server |
vi /home1/replication/Mysql-187/etc/my.cnf |
[client] port = 3307 [mysqld] user=mysql old_passwords=1 expire_logs_days = 30 max_binlog_size = 100M port = 3307 datadir=/home1/replication/Mysql-187/data/ pid-file = /home1/replication/Mysql-187/data/mysqld_3307.pid log = /home1/replication/Mysql-187/data/mysql_general.log socket = /home1/replication/Mysql-187/data/mysql.sock #skip-locking skip-external-locking group_concat_max_len=20480 #log general_log ####################### key_buffer = 128M max_allowed_packet = 8M table_cache = 5000 sort_buffer_size = 120M read_buffer_size = 120M read_rnd_buffer_size = 640M myisam_sort_buffer_size = 120M thread_cache = 128 tmp_table_size = 256M query_cache_size = 320M thread_concurrency = 32 max_connections = 100 max_user_connections = 100 max_connect_errors = 99999999 interactive_timeout=280 wait_timeout=280 skip-name-resolve slave-skip-errors = 1062,1053 ######################## innodb_buffer_pool_size = 200M innodb_additional_mem_pool_size = 200M innodb_log_buffer_size = 32M innodb_flush_log_at_trx_commit = 0 innodb_lock_wait_timeout = 256 innodb_flush_method = O_DIRECT innodb_thread_concurrency = 40 innodb_open_files = 2000 innodb_file_per_table log_bin_trust_function_creators = 1############ Replication ##################### server-id=153 master-host=11.11.18.81 master-user=replication-user master-password=replication-password #master-port=3306 #if master run on a different port log-bin = /home1/replication/Mysql-187/master-bin.log log-bin-index = /home1/replication/Mysql-187/master-log-bin.index show-slave-auth-info replicate-same-server-id=0 relay-log = /home1/replication/Mysql-187/slave-relay.log relay-log-index = /home1/replication/Mysql-187/slave-relay-log.index log-slave-updates log_output=FILE slow_query_log=1 slow_query_log_file=/home1/replication/Mysql-187/slow_queries.log long_query_time=3 log-slow-admin-statements ######################## [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash [isamchk] key_buffer = 256M sort_buffer_size = 256M read_buffer = 20M write_buffer = 20M [myisamchk] key_buffer = 1024M sort_buffer_size = 512M read_buffer = 64M write_buffer = 64M[mysqld_safe] log-error=/home1/replication/Mysql-187/mysqld.err pid-file=/home1/replication/Mysql-187/mysqld.pid |