How To Install MySQL 5.7 On Linux

MySQL is the most popular open-source RDBMS now a days. In our guide, we will come to know how to install MySQL 5.7 on a Linux server. 

Software / Binary Download

To download MySQL binary please visit it’s official site. If you are unable to find the desired version click on archive section as described.

Binary Download

Select the operating system and OS Version to download the edsired version. If the desired version isn’t available, then click on Archives and check for the desired version.

Software Selection Download

Click on download besides Compressed TAR Archive and copy the Link Address from “No thanks, just start my download“. Please save it in a Notepad for future reference, required during installation.

Link Copy

Create Required Directories

mkdir -p /mysqldatabase/RCAPS/admin/

mkdir -p /mysqldatabase/RCAPS/logs/

mkdir -p /mysqldatabase/RCAPS/tmp

mkdir -p /mysqldatabase/RCAPS/data

mkdir -p /mysqldatabase/RCAPS/binlogs 

mkdir -p /mysqldatabase/product/binary

Download Setup File, Unzip and Create Soft Link

cd /mysqldatabase/product/binary

$ wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
$ tar -zxvf mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz

Create Soft Link –

ln -s mysql-5.7.35-linux-glibc2.12-x86_64 5.7.35

Create my.cnf File

vi /mysqldatabase/RCAPS/admin/my.cnf

[client]

port = 3306

socket = /mysqldatabase/RCAPS/admin/mysql.sock

 

[mysqld_safe]

log-error=/mysqldatabase/RCAPS/logs/mysql.log

 

[mysqld]

port = 3306

socket = /mysqldatabase/RCAPS/admin/mysql.sock

max_allowed_packet = 32M

query_cache_size = 32M

table_open_cache = 512K

sort_buffer_size = 4M

read_buffer_size = 2M

read_rnd_buffer_size = 4M

myisam_sort_buffer_size = 4M

thread_cache_size = 25

sql_mode=ANSI,TRADITIONAL,NO_BACKSLASH_ESCAPES

log_output=TABLE

key_buffer_size = 32M

max_connections=100

tmp_table_size=32M

character_set_server=utf8

tmpdir=/mysqldatabase/RCAPS/tmp

max_heap_table_size=32M

join_buffer_size=4M

basedir=/mysqldatabase/product/binary/5.7.35

datadir=/mysqldatabase/RCAPS/data

default_storage_engine=InnoDB

innodb_file_per_table

log-bin=/mysqldatabase/RCAPS/binlogs/RCAPS-mysql-bin

log-bin-trust-function-creators=1

sync_binlog=1

binlog_format=mixed

server-id = 1

net_read_timeout = 60

innodb_data_home_dir = /mysqldatabase/RCAPS/data

innodb_data_file_path = ibdata1:200M;ibdata2:200M:autoextend

innodb_buffer_pool_size = 4096M

innodb_log_file_size = 1024M

innodb_log_buffer_size= 512M

innodb_flush_log_at_trx_commit = 1 

innodb_lock_wait_timeout = 500

Install MySQL Binary

$ cd /mysqldatabase/product/binary/5.7.35

$ bin/mysqld –defaults-file=/mysqldatabase/RCAPS/admin/my.cnf –initialize –user=mysql

2022-02-01T16:01:46.428149Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 1048686)

2022-02-01T16:01:46.428271Z 0 [Warning] Changed limits: table_open_cache: 457 (requested 524288)

2022-02-01T16:01:46.428597Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details).

 100 200

 100 200

 100 200 300 400 500 600 700 800 900 1000

 100 200 300 400 500 600 700 800 900 1000

2022-02-01T16:01:53.053944Z 0 [Warning] InnoDB: New log files created, LSN=45791

2022-02-01T16:01:53.113695Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2022-02-01T16:01:53.191290Z 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: e4fc1dfb-22d0-11ec-9497-0800271f22df.

2022-02-01T16:01:53.192417Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed’ cannot be opened.

2022-02-01T16:01:53.923155Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.

2022-02-01T16:01:53.923182Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.

2022-02-01T16:01:53.928363Z 0 [Warning] CA certificate ca.pem is self signed. 

2022-02-01T16:01:54.344747Z 1 [Note] A temporary password is generated for root@localhost: Mu,jT7!jC?=&

Note – From the installation log you will get the temporary password for root. In our case it’s Mu,jT7!jC?=&. 

Start the Instance and Change the root Password

$ bin/mysqld_safe --defaults-file=/mysqldatabase/TEST/admin/my.cnf --user=mysql &

$ /mysqldatabase/product/binary/5.7.35/bin/mysql -h127.0.0.1 -P3306 -uroot -p

( Use password from mysqld.log and change the password as mentioned )

mysql>  ALTER USER 'root'@'localhost' IDENTIFIED BY 'mysql';

Leave a Comment

Your email address will not be published. Required fields are marked *