Ask Me

Installation of MySQL Database on Oracle Linux 7 using Generic Binaries

 


Step 1 . Oracle provides a set of binary distributions of MySQL. These include generic binary distributions in the form of compressed tar files (files with a .tar.gz extension) for a number of platform .
  • Download it from mysql site.
  • https://downloads.mysql.com/archives/
  • Select your version and platform and download the .tar type
  • Ex. Red Hat Enterprise Linux 7 / Oracle Linux 7 (x86, 64-bit), TAR
  • Downloaded file  mysql-5.7.28-el7-x86_64.tar.gz

Step 2. Remove previous versions of installed binary 

Checking installed               ---------     rpm -qa | egrep mysql

Uninstall existing ones        ---------     rpm -e mysql.XXXXXXXX

Step 3: Unzip  files where you wanted to keep the mysql binary (Base Directory)
            Here i did it on /u01/mysql path and the directory Structure. 

[root@xcell oradba]# tar -xzvf mysql-5.7.28-el7-x86_64.tar.gz -C /u01/mysql

[root@xcell mysql-5.7.28-el7-x86_64]# ls -lrt
total 312
-rw-r--r--.  1 7161 31415    587 Sep 27  2019 README
-rw-r--r--.  1 7161 31415 279547 Sep 27  2019 LICENSE
drwxr-xr-x.  3 root root    4096 Apr 24 22:46 include
drwxr-xr-x.  4 root root    4096 Apr 24 22:46 man
drwxr-xr-x.  2 root root    4096 Apr 24 22:47 bin - 
drwxr-xr-x.  2 root root    4096 Apr 24 22:47 support-files
drwxr-xr-x. 28 root root    4096 Apr 24 22:47 share
drwxr-xr-x.  5 root root    4096 Apr 24 22:47 lib
drwxr-xr-x.  2 root root    4096 Apr 24 22:47 docs

DirectoryContents of Directory
bin mysqd server, client and utility programs
docsMySQL manual in Info format
manUnix manual pages
includeInclude (header) files
libLibraries
shareError messages, dictionary, and SQL for database installation
support-filesMiscellaneous support files

Step 4: Add necessary users 

groupadd mysql
useradd -r -g mysql -s /bin/false mysql
chown mysql:mysql /u01/mysql

Step 5: Go to the binary location and support-files directory ,
create the config file or Option file

EX. My.cnf

[root@xcell support-files]# ls -lrt
total 28
-rw-r--r--. 1 mysql mysql   773 Sep 27  2019 magic
-rwxr-xr-x. 1 mysql mysql 10576 Sep 27  2019 mysql.server
-rwxr-xr-x. 1 mysql mysql   894 Sep 27  2019 mysql-log-rotate
-rwxr-xr-x. 1 mysql mysql  1061 Sep 27  2019 mysqld_multi.server

-rw-r--r--. 1 mysql mysql   177 Apr 24 23:00 my.cnf

Also create a soft link in below location


[root@xcell ~]# ls -lrt /etc/my.cnf
lrwxrwxrwx. 1 root root 55 Apr 25 16:31 /etc/my.cnf -> /u01/mysql/mysql-5.7.28-el7-x86_64/support-files/my.cnf

[root@xcell ~]#

[root@xcell ~]# cat /etc/my.cnf
[mysqld]
server-id=2                                        -- Serverid (for multiple serv)
socket=/u01/mysql/mysql-5.7.28-el7-x86_64/mysql.sock  -- socket file
port=3307                                             -- port (default 3306)
basedir=/u01/mysql/mysql-5.7.28-el7-x86_64
general-log
datadir=/u01/mysql/mysql-5.7.28-el7-x86_64/data  --- location for new database
max_binlog_size=4096
log-bin=mysql

[client]                   -- Client Option used for client conn as root or os auth
socket=/u01/mysql/mysql-5.7.28-el7-x86_64/mysql.sock
[root@xcell ~]#


Step 6: Go back to Bin location inside binary

[root@xcell bin]# ./mysqld --defaults-file=/u01/mysql/mysql-5.7.28-el7-x86_64/support-files/my.cnf --user=mysql --initialize 2020-04-24T18:05:03.535086Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.
Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2020-04-24T18:05:04.298446Z 0 [Warning] InnoDB: New log files created, LSN=45790 2020-04-24T18:05:04.627597Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2020-04-24T18:05:04.701383Z 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: 1fcc4cde-8656-11ea-8b82-08002743c30b. 2020-04-24T18:05:05.042753Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2020-04-24T18:05:09.874302Z 0 [Warning] CA certificate ca.pem is self signed. 2020-04-24T18:05:10.591258Z 1 [Note] A temporary password is generated for root@localhost: r5g:+l9&jecG [root@xcell bin]#


root@devserver support-files]# ls
magic  my.cnf  mysqld_multi.server  mysql-log-rotate  mysql.server
[root@devserver support-files]# ls -lrt
total 28
-rw-r--r--. 1 mysql mysql   773 Sep 27  2019 magic
-rwxr-xr-x. 1 mysql mysql 10576 Sep 27  2019 mysql.server
-rwxr-xr-x. 1 mysql mysql   894 Sep 27  2019 mysql-log-rotate
-rwxr-xr-x. 1 mysql mysql  1061 Sep 27  2019 mysqld_multi.server
-rw-r--r--. 1 mysql mysql   341 May 10 14:33 my.cnf
[root@devserver support-files]# ./mysql.server start


Step 7: Secure your installation using the above auto generated root pass
and change the user pass

mysql_secure_installation --defaults-file=/u01/mysql/mysql-5.7.28-el7-x86_64/support-files/my.cnf
socket=/u01/mysql/mysql-5.7.28-el7-x86_64/mysql2.sock

Securing the MySQL server deployment.


Enter password for user root:

Step 8: Configure the mysqld as a linux service.

[root@xcell system]# cat /etc/systemd/system/mysqld.service
[Unit]Description=MYSQL service
After=network.target
[Service]
Type=simple
Restart=always
RestartSec=1
User=rootExec
Start= /u01/mysql/mysql-5.7.28-el7-x86_64/bin/mysqld
--defaults-file=/u01/mysql/mysql-5.7.28-el7-x86_64/support-files/my.cnf --user=root
[Install]
WantedBy=multi-user.target


[root@xcell system]# service mysqld start

Redirecting to /bin/systemctl start  mysqld.service

[root@xcell system]# service mysqld statusRedirecting to /bin/systemctl status  mysqld.service
● mysqld.service - MYSQL service   Loaded: loaded (/etc/systemd/system/mysqld.service; disabled; vendor preset: disabled)   

Active: active (running) since Sat 2020-04-25 00:14:35 IST; 3s ago Main PID: 10389 (mysqld)   CGroup: /system.slice/mysqld.service           

└─10389 /u01/mysql/mysql-5.7.28-el7-x86_64/bin/mysqld --defaults-file=/u01/mysql/mysql-5.7.28-el7-x86_64/support-files/my.cnf --user=rootApr 25 00:14:36

xcell.home.com mysqld[10389]: 2020-04-24T18:44:36.036985Z 0 [Warning] CA certificate ca.pem is self signed.Apr 25 00:14:36

xcell.home.com mysqld[10389]: 2020-04-24T18:44:36.037039Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.Apr 25 00:14:36

xcell.home.com mysqld[10389]: 2020-04-24T18:44:36.037249Z 0 [Note] Server hostname (bind-address): '*'; port: 3307Apr 25 00:14:36

xcell.home.com mysqld[10389]: 2020-04-24T18:44:36.037299Z 0 [Note] IPv6 is available.Apr 25 00:14:36 xcell.home.com mysqld[10389]: 2020-04-24T18:44:36.037316Z 0 [Note]   - '::' resolves to '::';Apr 25 00:14:36

xcell.home.com mysqld[10389]: 2020-04-24T18:44:36.037348Z 0 [Note] Server socket created on IP: '::'.Apr 25 00:14:36

xcell.home.com mysqld[10389]: 2020-04-24T18:44:36.051042Z 0 [Note] Failed to start slave threads for channel ''Apr 25 00:14:36

xcell.home.com mysqld[10389]: 2020-04-24T18:44:36.063109Z 0 [Note] Event Scheduler: Loaded 0 eventsApr 25 00:14:36

xcell.home.com mysqld[10389]: 2020-04-24T18:44:36.063823Z 0 [Note] /u01/mysql/mysql-5.7.28-el7-x86_64/bin/mysqld: ready for connections.Apr 25 00:14:36

xcell.home.com mysqld[10389]: Version: '5.7.28'  socket: '/u01/mysql/mysql-5.7.28-el7-x86_64/mysql2.sock'  port: 3307  MySQL Community Server (GPL)Hint: Some lines were ellipsized, use -l to show in full.

[root@xcell system]#


Popular Posts