Centos7 install mysql5.6.29 shell script

Centos7 install mysql5.6.29 shell script

This article shares the shell script of mysql5.6.29 for your reference. The specific content is as follows

Create a script mysql.sh and run sh mysql.sh directly

#!/bin/bash
if [ -d /software ] ;then
  cd /software
else
  mkdir /software && cd /software
fi

#is exist command ,if not,yum install
is_exist() {
  which $1
  if [ $? -ne 0 ] ;then
     yum -y install $1
  fi
}

#dolovnad the mysql install package,if exist,check the md5sum,if correct,tar;else rm and download
if [ -f mysql-5.6.29.tar.gz ] ;then
  mysql_md5=`md5sum mysql-5.6.29.tar.gz | cut -d " " -f 1 `
  mysql_md5_true="aaa21c6450adee3a1894fd1710f02bf5"
  if [ "$mysql_md5" = "$mysql_md5_true" ] ;then
    tar -zxvf mysql-5.6.29.tar.gz
  else
    rm -rf mysql-5.6.29.tar.gz
   rm -rf mysql-5.6.29
  fi
else
  is_exist wget
  wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.29.tar.gz
  tar -zxvf mysql-5.6.29.tar.gz
fi

#see the yum source is used
yum cleanup
yum makecache

#install the depend package
yum -y install gcc make cmake ncurses-devel libxml2-devel libtool-ltdl-devel gcc-c++ autoconf automake bison zlib-devel

#add mysql group and user
is_user_mysql=`cat /etc/passwd |awk -F ":" '{print $1}' |grep mysql`
is_group_mysql=`cat /etc/group |awk -F ":" '{print $1}' |grep mysql`

if [ "$is_group_mysql" != "mysql" ] ;then
  groupadd mysql
fi
if [ "$is_user_mysql" != "mysql" ] ;then
   useradd -r -s /sbin/nologin -g mysql mysql
fi

#compile and install
cd mysql-5.6.29
cmake .
make && make install

chown -R mysql.mysql /usr/local/mysql

#init database
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data

#copy the important file to /etc
#cp /usr/local/mysql/my.cnf /etc/my.cnf

sed -i 's/\# basedir \= ...../basedir \= \/usr\/local\/mysql/g' /usr/local/mysql/my.cnf
sed -i 's/\# port = ...../port = 3306/g' /usr/local/mysql/my.cnf
sed -i 's/\# datadir \= ...../datadir \= \/usr\/local\/mysql\/data/g' /usr/local/mysql/my.cnf
sed -i '/\[mysqld\]/a\log-error=\/usr\/local\/mysql\/log\/error.log' /usr/local/mysql/my.cnf
#sed -i '/\[mysqld\]/a\log=\/usr\/local\/mysql\/log\/log' /usr/local/mysql/my.cnf
#sed -i '/\[mysqld\]/a\log-slow-queries=\/usr\/local\/mysql\/log\/slowquery.log' /usr/local/mysql/my.cnf
sed -i '/\[mysqld\]/a\long_query_time=2' /usr/local/mysql/my.cnf
sed -i '/\[mysqld\]/a\pid-file=\/usr\/local\/mysql\/data\/mysql.pid' /usr/local/mysql/my.cnf
sed -i '/\[mysqld\]/a\character-set-server=utf8' /usr/local/mysql/my.cnf

echo "[client] " >> /usr/local/mysql/my.cnf
echo "socket = /var/lib/mysql/mysql.sock" >>/usr/local/mysql/my.cnf

/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
#use database
/usr/local/mysql/bin/mysqld_safe --user=mysql &

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on

`ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock`
#start the service
service mysqld restart

#import environment
PATH=$PATH:/usr/local/mysql/bin
echo "export PATH=$PATH:/usr/local/mysql/bin >> /etc/profile"
source /etc/profile

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • MySQL 5.7 installation and configuration tutorial under CentOS7 64 bit
  • Detailed steps to install MySQL on CentOS 7
  • A concise tutorial on how to install mysql5.7 decompressed version on CentOS7
  • Centos7 installation and configuration of Mysql5.7
  • MySQL 5.7.17 installation and configuration tutorial under CentOS6.9
  • Detailed tutorial on installing Mysql5.7.19 on Centos7 under Linux
  • How to install mysql5.6 on centos7
  • How to install MySQL on CentOS 7 and set it to start automatically
  • The process of installing MySQL 8.0.26 on CentOS7

<<:  How to write asynchronous tasks in modern JavaScript

>>:  A universal nginx interface to implement reverse proxy configuration

Recommend

Summary of MySQL time statistics methods

When doing database statistics, you often need to...

Pure CSS to achieve cool charging animation

Let’s take a look at what kind of charging animat...

Difference between varchar and char types in MySQL

Table of contents aforementioned VARCHAR Type VAR...

Detailed explanation of CSS text decoration text-decoration &amp; text-emphasis

In CSS, text is one of the most common things we ...

Core skills that web front-end development engineers need to master

The content involved in Web front-end development...

HTML table only displays the outer border of the table

I would like to ask a question. In Dreamweaver, I...

Implementing countdown effect with javascript

Use Javascript to achieve the countdown effect, f...

The new version of Chrome browser settings allows cross-domain implementation

Preface Currently, the front-end solves cross-dom...

Eight rules for effective web forms

If you're collecting information from your us...

Vue implements card flip carousel display

Vue card flip carousel display, while switching d...

How complicated is the priority of CSS styles?

Last night, I was looking at an interview question...

Implementation of Docker Compose multi-container deployment

Table of contents 1. WordPress deployment 1. Prep...

Detailed tutorial on deploying Django project under CentOS

Basic Environment Pagoda installation service [Py...

Introduction to the usage of exists and except in SQL Server

Table of contents 1. exists 1.1 Description 1.2 E...