Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and deploy MySQL5.7

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Next, let's learn how to install and deploy MySQL5.7. I believe everyone will benefit a lot after reading it. The text is not much in essence. I hope you want to install and deploy MySQL5.7.

Part1: write at the front

MYSQL5.7.15 is the latest community version of the official website of mysql as of the date of writing of this article. Many functional optimizations of mysql5.7 can be described as exciting and troublesome to install.

Part2: just installing it is enough?

No, of course not. Many features of MySQL5.7 have been updated, so we can't repeat them one by one. Therefore, let's first interpret some of the new features of MySQL5.7 from my.cnf, which is most relevant to this article.

Earlier I wrote about new feature parameters for MySQL5.6, such as:

Innodb_buffer_pool_dump_at_shutdown=1

Innodb_buffer_pool_load_at_startup=1

Turn on these two parameters to reload the hot data when the database is restarted.

Only normal library shutdown will lead to dump hot data blocks, downtime and kill-9 will not.

More 5.6 installation can be moved:

Https://cache.yisu.com/upload/information/20200310/34/96296.com

Note: in MariaDB10.1, this parameter is also provided, but the default value is 100

Adjust innodb_buffer_pool_size online without restarting the mysql process

In MySQL5.6/MariaDB version 10.1, adjusting this parameter must restart the MySQL process to take effect, while in the mysql5.7 version, it can be set directly and dynamically, which is very convenient.

This feature is used in scenarios such as:

1. The machine added new memory. DBA forgot to increase this parameter.

two。 When the job was handed over, the new DBA found that the previous DBA set the parameter improperly.

The following test is carried out in my machine, changing 512m memory to 256m, as shown in the following figure:

WKioL1fjdMSSu3ApAAES8CSuJE4611.jpg

It is important to note that during the adjustment of the buffer_pool, the user's request will be blocked until the adjustment is complete, so do not adjust during the peak period.

Ql#

# slow log directory / data/slowlog#

# Port number defaults to 3306. Other parameters are modified as needed. #

#

# author:rrhelei@126.com#

#

#! / bin/bash

# Check if user is root

If [$(id-u)! = "0"]; then

Echo "Error: You must be root to run this script, please use root to install"

Exit 1

Fi

Clear

Echo "="

Echo "A tool to auto-compile & install MySQL 5.7.15 on Redhat/CentOS Linux"

Echo "="

Cur_dir=$ (pwd)

# set mysql root password

Echo "= ="

Mysqlrootpwd= "MANAGER"

Echo-e "Please input the root password of mysql:"

Read-p "(Default password: MANAGER):" mysqlrootpwd

If ["$mysqlrootpwd" = ""]; then

Mysqlrootpwd= "MANAGER"

Fi

Echo "= ="

Echo "MySQL root password:$mysqlrootpwd"

Echo "= ="

# which MySQL Version do you want to install?

Echo "= ="

Isinstallmysql57= "n"

Echo "Install MySQL 5.7.15 Please input y"

Read-p "(Please input y, n):" isinstallmysql57

Case "$isinstallmysql57" in

Y | Y | Yes | YES | yes | yES | yEs | YeS | yeS)

Echo "You will install MySQL 5.7.15"

Isinstallmysql57= "y"

*)

Echo "INPUT error,You will exit install MySQL 5.7.15"

Isinstallmysql57= "n"

Exit

Esac

Get_char ()

{

SAVEDSTTY= `stty-g`

Stty-echo

Stty cbreak

# dd if=/dev/tty bs=1 count=1 2 > / dev/null

Stty-raw

Stty echo

Stty $SAVEDSTTY

}

Echo ""

Echo "Press any key to start...or Press Ctrl+c to cancel"

Char= `get _ char`

# Initialize the installation related content.

Function InitInstall ()

{

Cat / etc/issue

Uname-a

MemTotal= `free-m | grep Mem | awk'{print $2}'`

Echo-e "\ n Memory is: ${MemTotal} MB"

# Set timezone

# rm-rf / etc/localtime

# ln-s / usr/share/zoneinfo/Asia/Shanghai / etc/localtime

# Delete Old Mysql program

Rpm-qa | grep mysql

Rpm-e mysql

# Disable SeLinux

If [- s / etc/selinux/config]; then

Sed-I's etc/selinux/config SelinuxplenforcingAccording to SELINUXAfter

Fi

Setenforce 0

}

# Installation of depend on and optimization options.

Function InstallDependsAndOpt ()

{

Cd $cur_dir

Cat > > / etc/security/limits.conf / etc/sysctl.conf

}

# Install MySQL

Function InstallMySQL57 ()

{

Echo "= = Install MySQL 5.7.15"

Cd $cur_dir

# Backup old my.cnf

# rm-f / etc/my.cnf

If [- s / etc/my.cnf]; then

Mv / etc/my.cnf / etc/ my.cnf.`date +% Y% m% d% H% M% S`.bak

Fi

Echo "= MySQL 5.7.15 installing. ="

# mysql directory configuration

Tar xvf / root/mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz

Mv / root/mysql-5.7.15-linux-glibc2.5-x86_64 / usr/local/mysql

Groupadd mysql-g 512

Useradd-u 512-g mysql-s / sbin/nologin-d / home/mysql mysql

Mkdir-p / data/mysql

Mkdir-p / data/slowlog

Chown-R mysql:mysql / data/mysql

Chown-R mysql:mysql / usr/local/mysql

Chown-R mysql:mysql / data/slowlog

# edit / etc/my.cnf

SERVERID= `ifconfig eth0 | grep "inet addr" | awk'{print $2}'| awk-F. '{print $3 $4}' `

Cat > > / etc/my.cnf / etc/ld.so.conf.d/mysql-x86_64.conf / etc/profile / dev/null

CheckInstall 2 > & 1 | tee-a / root/mysql-install.log

Part5: log in & enjoy it

1. First source the environment variable file to make it effective

[root@HE2 ~] source / etc/profile

two。 Enter the user name and password (default is MANAGER) to log in to the database

WKioL1fg55bRtezyAAEwCj3jwm4534.jpg

At this point, the MySQL5.7.15 installation is complete

After reading this article on how to install and deploy MySQL5.7, many readers will want to know more about it. For more industry information, you can follow our industry information section.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report