Steps to configure 2 different version of MySQL servers (i.e. 5.7 and 8.023) on a Single Oracle Linux host
=====================================
Pre-requisites
=====================================
Pre-requisites
=====================================
# Remove any priori installations of mysql
[root]# rpm -qa|grep mysql
[root]# rpm -qa |grep mariadb-libs
[root]# yum remove mariadb-libs -y
[root]# groupadd mysql
[root]# useradd -r -g mysql -s /bin/false mysql
[root]# useradd -r -g mysql -s /bin/false mysql
=====================================
MYSQL VERSION 8.023 Untar
=====================================
cd /home/mysql_download/
tar -xzvf mysql-8.0.23-el7-x86_64.tar.gz -C /usr/local
=====================================
MYSQL VERSION 5.7 Untar
=====================================
cd /home/mysql_download/
tar -xzvf mysql-5.7.41-el7-x86_64.tar.gz -C /usr/local
=====================================
MYSQL VERSION 8.023 Dir Link Creation
=====================================
sudo ln -s /usr/local/mysql-8.0.23-el7-x86_64 mysql
=====================================
MYSQL VERSION 5.7 Dir Link Creation
=====================================
sudo ln -s /usr/local/mysql-5.7.41-el7-x86_64 mysql_5-7
=====================================
MYSQL VERSION 8.023 Dir Creation
=====================================
mkdir -p /usr/local/mysql/{3306,3307}/data
=====================================
MYSQL VERSION 5.7 Dir Creation
=====================================
=====================================
mkdir -p /usr/local/mysql_5-7/{3308,3309}/data
=====================================
MYSQL VERSION 8.023 Bash Profile
=====================================
vi ~/.profile_mysqlver8
. ~/.bash_profile
export PATH=$PATH:/usr/local/mysql/bin
export MYSQL_VER8_BASE=/usr/local/mysql
export MYSQL_VER8_3306_DATA=/usr/local/mysql/3306/data
export MYSQL_VER8_3306_CONF=/usr/local/mysql/3306/my.cnf
export MYSQL_VER8_3306_LOG=/usr/local/mysql/3306/data/mysql06.log
=====================================
MYSQL VERSION 5.7 Bash Profile
=====================================
vi ~/.profile_mysqlver5-7
. ~/.bash_profile
export PATH=$PATH:/usr/local/mysql_5-7/bin
export MYSQL_VER5-7_BASE=/usr/local/mysql_5-7
export MYSQL_VER5-7_3308_DATA=/usr/local/mysql_5-7/3308/data
export MYSQL_VER5-7_3308_CONF=/usr/local/mysql_5-7/3308/my.cnf
export MYSQL_VER5-7_3308_LOG=/usr/local/mysql_5-7/3308/data/mysql08.log
=====================================
MYSQL VERSION 8.023
=====================================
vi /usr/local/mysql/3306/my.cnf
Example 1 (3306)
[mysqld]
port = 3306
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/3306/data
lower_case_table_names=1
bind-address=192.168.226.130
innodb_buffer_pool_size=128M
socket=/tmp/mysql_3306.sock
log_error=/usr/local/mysql/3306/data/mysql06.log
=====================================
MYSQL VERSION 5.7
=====================================
vi /usr/local/mysql_5-7/3308/my.cnf
Example 3 (3308)
[mysqld]
port = 3308
basedir=/usr/local/mysql_5-7
datadir=/usr/local/mysql_5-7/3308/data
lower_case_table_names=1
bind-address=192.168.226.131
innodb_buffer_pool_size=128M
socket=/tmp/mysql_5-7_3308.sock
log_error=/usr/local/mysql_5-7/3308/data/mysql08.log
=====================================
MYSQL VERSION 8.023
=====================================
chown -R mysql:mysql mysql
=====================================
MYSQL VERSION 5.7
=====================================
chown -R mysql:mysql mysql_5-7
=====================================
Workaround for Library requirement by Tar ball
=====================================
ln -s /usr/lib64/libncurses.so.6.1 /usr/lib64/libncurses.so.5
ln -s /usr/lib64/libtinfo.so.6.1 /usr/lib64/libtinfo.so.5
=====================================
MYSQL VERSION 8.023
=====================================
/usr/local/mysql/bin/mysqld --defaults-file=/usr/local/mysql/3306/my.cnf --initialize --user=mysql
cd /usr/local/mysql/3306/data/
cd /usr/local/mysql/3306/data/
view mysql06.log
2023-05-25T03:43:56.760610Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.23) initializing of server in progress as process 645533
2023-05-25T03:43:56.778574Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-05-25T03:43:57.286895Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-05-25T03:43:58.585871Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ;pKhF1x#.GWs
2023-05-27T19:17:51.466038Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.23) initializing of server in progress as process 248724
2023-05-27T19:17:51.510126Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-05-27T19:17:53.199732Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-05-27T19:17:54.643677Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: rue7iY>tpaT<
Started db:-
nohup /usr/local/mysql/bin/mysqld --defaults-file=/usr/local/mysql/3306/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/3306/data --user=mysql &
Shutdown db:-
mysqladmin -u root -p -S /tmp/mysql_3306.sock shutdown
Connect to Mysql:-
mysql -S /tmp/mysql_3306.sock -p
Reset root password: -
mysql> alter user 'root'@'localhost' identified by 'Oracle123';
mysql> flush privileges;
*********************************************
- Register mysql as a service
*********************************************
vi /etc/systemd/system/mysql_Ver8.service
[Unit]
Description=MySQL Server
Documentation=https://dev.mysql.com/doc/refman/8.0/en/
After=network.target
[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/usr/local/mysql/3306/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/3306/data --user=mysql
ExecStop=/usr/local/mysql/bin/mysqladmin --user=root -pOracle123 --socket=/tmp/mysql_3306.sock shutdown
#ExecStartPost=/usr/local/mysql/bin/mysql_upgrade -u root -pOracle123
Restart=always
TimeoutSec=30
RestartSec=3
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable mysql_Ver8
systemctl daemon-reload
systemctl disable mysql_Ver8
systemctl daemon-reload
systemctl start mysql_Ver8
systemctl stop mysql_Ver8
=====================================
MYSQL VERSION 5.7
=====================================
export PATH=$PATH:/usr/local/mysql_5-7/bin
/usr/local/mysql_5-7/bin/mysqld --defaults-file=/usr/local/mysql_5-7/3308/my.cnf --initialize --user=mysql
cd /usr/local/mysql_5-7/3308/data
cat mysql08.log
total 110664
-rw-r-----. 1 mysql mysql 50331648 May 25 11:18 ib_logfile1
-rw-r-----. 1 mysql mysql 56 May 25 11:18 auto.cnf
-rw-------. 1 mysql mysql 1680 May 25 11:18 ca-key.pem
-rw-r--r--. 1 mysql mysql 1112 May 25 11:18 ca.pem
-rw-------. 1 mysql mysql 1676 May 25 11:18 server-key.pem
-rw-r--r--. 1 mysql mysql 1112 May 25 11:18 server-cert.pem
-rw-------. 1 mysql mysql 1680 May 25 11:18 client-key.pem
-rw-r--r--. 1 mysql mysql 1112 May 25 11:18 client-cert.pem
-rw-r--r--. 1 mysql mysql 452 May 25 11:18 public_key.pem
-rw-------. 1 mysql mysql 1676 May 25 11:18 private_key.pem
-rw-r-----. 1 mysql mysql 1108 May 25 11:18 mysql08.log
drwxr-x---. 2 mysql mysql 8192 May 25 11:18 performance_schema
drwxr-x---. 2 mysql mysql 4096 May 25 11:18 mysql
drwxr-x---. 2 mysql mysql 8192 May 25 11:18 sys
-rw-r-----. 1 mysql mysql 436 May 25 11:18 ib_buffer_pool
-rw-r-----. 1 mysql mysql 50331648 May 25 11:18 ib_logfile0
-rw-r-----. 1 mysql mysql 12582912 May 25 11:18 ibdata1
[root@ishanu1 data]# cat mysql08.log
2023-05-25T05:48:45.249159Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-05-25T05:48:45.584940Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-05-25T05:48:45.646895Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-05-25T05:48:45.668121Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: d02d4d65-fabf-11ed-af29-000c291b23e9.
2023-05-25T05:48:45.674552Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-05-25T05:48:45.867762Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2023-05-25T05:48:45.867774Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2023-05-25T05:48:45.868102Z 0 [Warning] CA certificate ca.pem is self signed.
2023-05-25T05:48:45.944221Z 1 [Note] A temporary password is generated for root@localhost: p(Sya-&qg7b>
2023-05-27T19:31:19.556493Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-05-27T19:31:19.683233Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-05-27T19:31:19.712006Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-05-27T19:31:19.721531Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 0e4fb5df-fcc5-11ed-8889-000c29fcefc9.
2023-05-27T19:31:19.722656Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-05-27T19:31:19.837979Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2023-05-27T19:31:19.837993Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2023-05-27T19:31:19.838444Z 0 [Warning] CA certificate ca.pem is self signed.
2023-05-27T19:31:19.853244Z 1 [Note] A temporary password is generated for root@localhost: -Wg<ve?&j1G,
Started db:-
nohup /usr/local/mysql_5-7/bin/mysqld --defaults-file=/usr/local/mysql_5-7/3308/my.cnf --basedir=/usr/local/mysql_5-7 --datadir=/usr/local/mysql_5-7/3308/data --user=mysql &
Shutdown db:-
/usr/local/mysql_5-7/bin/mysqladmin --user=root -pOracle123 --socket=/tmp/mysql_3308.sock
shutdown
Connect to Mysql:-
mysql -S /tmp/mysql_5-7_3308.sock -p
Reset root password: -
mysql> alter user 'root'@'localhost' identified by 'Oracle123';
mysql> flush privileges;
*********************************************
- Register mysql as a service
*********************************************
vi /etc/systemd/system/mysql_Ver5-7.service
[Unit]
Description=MySQL Server
Documentation=https://dev.mysql.com/doc/refman/8.0/en/
After=network.target
[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql_5-7/bin/mysqld --defaults-file=/usr/local/mysql_5-7/3308/my.cnf --basedir=/usr/local/mysql_5-7 --datadir=/usr/local/mysql_5-7/3308/data --user=mysql
ExecStop=/usr/local/mysql_5-7/bin/mysqladmin --user=root -pOracle123 -P3308 --socket=/tmp/mysql_5-7_3308.sock shutdown
#ExecStartPost=/usr/local/mysql_5-7/bin/mysql_upgrade -u root -pOracle123
Restart=always
TimeoutSec=30
RestartSec=3
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable mysql_Ver5-7
systemctl daemon-reload
systemctl disable mysql_Ver5-7
systemctl daemon-reload
systemctl start mysql_Ver5-7
systemctl stop mysql_Ver5-7
=====================================



Comments
Post a Comment