MySQL 5.6.24 (binary) automatic installation script under Linux

MySQL 5.6.24 (binary) automatic installation script under Linux

This article shares the mysql5.6.24 automatic installation script code in Linux environment for your reference. The specific content is as follows

illustrate:

1. This script is for testing only . If you want to use it in a formal environment, you need to change some parameters of the script.

2. Before using this script, you need to ensure that the Linux environment can be downloaded online . If you cannot connect to the Internet, you need to upload the downloaded MySQL binary package to the /data directory in Linux.

3. To use the script, you need to enter three parameters at a time:

1. The MySQL version number to be installed, such as: 5.6.24

2. The mysql port setting to be installed, such as: 3306

3. Set the server_id of mysql, such as: 1003306

Steps:

1. Upload the following script to the Linux environment. I personally named it mysql_install.sh

#!/bin/bash 
#mysql_install by chen 
#Email: [email protected] & [email protected] 
#version 2.0 
#Install version 5.6.20-5.6.25 
#Installation requirements: 
#You need to be able to connect to the Internet. If there is no network, you can create the /data directory first and upload the installation package to the /data directory. #Judge whether the /data directory exists. If not, create it and download mysql 
datamenu="/data" 
read -p "Input a mysql version:" -t 30 mysql_version 
read -p "Input a mysql port:" -t 30 mysql_port 
read -p "Input a mysql_server_id:" -t 30 mysql_server_id 
mysqlfile="$datamenu/mysql-$mysql_version-linux-glibc2.5-x86_64.tar.gz" 
 
if [ ! -d "$datamenu" ];then 
  mkdir "$datamenu" 
  wget -P /data http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-$mysql_version-linux-glibc2.5-x86_64.tar.gz 
elif [ ! -f "$mysqlfile" ];then 
  wget -P /data http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-$mysql_version-linux-glibc2.5-x86_64.tar.gz 
fi 
 
#Unzip the downloaded mysql 
cd /opt 
mkdir mysql 
cd mysql 
tar zxvf $mysqlfile -C /opt/mysql 
 
#Create mysql user egrep "^mysql" /etc/group >& /dev/null 
if [ $? -ne 0 ] 
then 
 groupadd mysql 
fi 
 
#create user if not exists 
egrep "^mysql" /etc/passwd >& /dev/null 
if [ $? -ne 0 ] 
then 
 useradd -g mysql -s /sbin/nologin -d /usr/local/mysql mysql 
fi 
 
 
#Create a mysql soft connection and authorize the mysql user cd /usr/local/ 
rm -rf /usr/local/mysql 
ln -s /opt/mysql/mysql-$mysql_version-linux-glibc2.5-x86_64 /usr/local/mysql 
chown -R mysql:mysql /usr/local/mysql 
chown -R mysql:mysql /usr/local/mysql/ 
 
#Based on the configuration file, create the mysql installation directory and authorize mkdir -p /data/mysql 
mkdir -p /data/mysql/mysql${mysql_port} 
cd /data/mysql/mysql${mysql_port}/ 
mkdir /data/mysql/mysql${mysql_port}/data 
mkdir /data/mysql/mysql${mysql_port}/logs 
mkdir /data/mysql/mysql${mysql_port}/tmp 
chown -R mysql:mysql /data/mysql/mysql${mysql_port} 
 
cat > /etc/my.cnf << EOF 
 
[client] 
port = ${mysql_port} 
socket = /tmp/mysql.sock 
 
# The MySQL server 
[mysqld] 
# Basic 
port = ${mysql_port} 
user = mysql 
basedir = /usr/local/mysql 
datadir = /data/mysql/mysql${mysql_port}/data 
tmpdir = /data/mysql/mysql${mysql_port}/tmp 
socket = /tmp/mysql.sock 
 
log-bin = /data/mysql/mysql${mysql_port}/logs/mysql-bin 
 
log-error = error.log 
slow-query-log-file = slow.log 
skip-external-locking 
skip-name-resolve 
log-slave-updates 
 
lower_case_table_names = 1 #Ignore table name case character_set_server = gbk 
innodb_file_per_table = 1 
innodb_autoinc_lock_mode = 2 
 
explicit_defaults_for_timestamp = true 
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
 
EOF 
 
 
# Initialize mysql 
 
cd /usr/local/mysql 
./scripts/mysql_install_db --defaults-file=/etc/my.cnf 
 
 
#Create mysql startup script under /etc/init.dcp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql 
 
 
#Add environment variables and make the /etc/profile environment variables effective echo "export PATH=$PATH:/usr/local/mysql/bin">>/etc/profile
export PATH=$PATH:/usr/local/mysql/bin 

2. Give the script executable permissions.

[root@zabbix-server ~]# rz -yz waiting to receive.**B0100000023be50 
[root@zabbix-server ~]# ls 
anaconda-ks.cfg install.log install.log.syslog mysql_install.sh 
[root@zabbix-server ~]# chmod +x mysql_install.sh 
[root@zabbix-server ~]# ls -al|grep mysql_install.sh 
-rwxr-xr-x. 1 root root 3136 Jul 29 10:29 mysql_install.sh 

3. Execute the script, enter three parameters, and wait for the database to be installed

[root@MySQL ~]# ./mysql_install.sh 
Input a mysql version:5.6.24 
Input a mysql port:3306 
Input a mysql_server_id:1003306 

4. Start the database

[root@MySQL ~]# /etc/init.d/mysql start 
Starting MySQL.. [ OK ] 
[root@zabbix-server ~]# mysql 
Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 1 
Server version: 5.6.24-log MySQL Community Server (GPL) 
 
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. 
 
Oracle is a registered trademark of Oracle Corporation and/or its 
affiliates. Other names may be trademarks of their respective 
owners. 
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 
 
mysql> show databases 
 -> ; 
+--------------------+ 
| Database | 
+--------------------+ 
| information_schema | 
|mysql | 
| performance_schema | 
| test | 
+--------------------+ 
4 rows in set (0.00 sec) 
 
mysql> 

At this point, the MySQL installation under Linux has been completed, and you can use it to do some tests.

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.18 binary package installation tutorial under Linux (without default configuration file my_default.cnf)
  • Deploy MySQL 5.7.17 binary installation and multi-instance configuration on CentOS 6.5
  • Detailed tutorial on customizing the installation path of MySQL 5.7.18 version (binary package installation)
  • How to install mysql5.7.24 binary version on Centos 7 and how to solve it
  • Centos7.5 installs mysql5.7.24 binary package deployment
  • Detailed tutorial on installing MySQL 5.7.11 for Linux Generic binary version in CentOS 7 via command line
  • Tutorial on installing MySQL 5.6.20 using Linux binary universal package
  • Install mysql5.6 in ubuntu system (through binary)
  • mysql 5.7.19 latest binary installation
  • The whole process record of MySQL binary installation and backup

<<:  A quick guide to Docker

>>:  Detailed explanation of JS homology strategy and CSRF

Recommend

CentOS7.x uninstall and install MySQL5.7 operation process and encoding format modification method

1. Uninstalling MySQL 5.7 1.1查看yum是否安裝過mysql cd y...

Summary of common knowledge points required for MySQL

Table of contents Primary key constraint Unique p...

MySQL database JDBC programming (Java connects to MySQL)

Table of contents 1. Basic conditions for databas...

Solution to 1067 when Mysql starts in Windows

I just started working a few days ago and install...

mysql5.5 installation graphic tutorial under win7

MySQL installation is relatively simple, usually ...

Talking about ContentType(s) from image/x-png

This also caused the inability to upload png files...

Detailed explanation of CSS3 flex box automatic filling writing

This article mainly introduces the detailed expla...

How to strike a balance between ease of use and security in the login interface

Whether you are a web designer or a UI designer, ...

css3 animation ball rolling js control animation pause

CSS3 can create animations, which can replace man...

js to realize a simple advertising window

This article shares the specific code of js to im...

Vue implements the drag and drop sorting function of the page div box

vue implements the drag and drop sorting function...

The whole process of developing a Google plug-in with vue+element

Simple function: Click the plug-in icon in the up...

MySQL server 5.7.20 installation and configuration method graphic tutorial

This article records the installation and configu...

Robots.txt detailed introduction

Robots.txt is a plain text file in which website ...