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

Mysql5.6 automated deployment

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Host environment: Centos6.5

Premise:

1. Configure yum Feed

two。 Remove the mysql that comes with the system

3. Delete previous mysql users

4. Use the mysql binary installation package: https://dev.mysql.com/downloads/file/?id=473278

[root@mysql ~] # ls-lrt

-rw-r--r-- 1 root root 328739574 Nov 11 00:40 mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz

-rw-r--r-- 1 root root 7302 Nov 11 00:41 mysql_auto_install.sh

-rw-r--r-- 1 root root 866364 Nov 11 00:46 mysql-install.log

Mysql_install.sh: be careful to replace the package version

[root@mysql ~] # cat mysql_auto_install.sh

# binary automatic installation database script root password mysqld put the script and installation package in the / root directory

# Database directory / usr/local/mysql#

# data directory / data/mysql#

# Log directory / log/mysql#

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

#

# author:rrhelei@126.com#

#

#! / bin/bash

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin:~/bin

Export PATH

# 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.6.38 on Redhat/CentOS Linux"

Echo "="

Cur_dir=$ (pwd)

# set mysql root password

Echo "= ="

Mysqlrootpwd= "mysqld"

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

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

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

Mysqlrootpwd= "mysqld"

Fi

Echo "= ="

Echo "MySQL root password:$mysqlrootpwd"

Echo "= ="

# which MySQL Version do you want to install?

Echo "= ="

Isinstallmysql56= "n"

Echo "Install MySQL 5.6.38 Please input y"

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

Case "$isinstallmysql56" in

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

Echo "You will install MySQL 5.6.38"

Isinstallmysql56= "y"

*)

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

Isinstallmysql56= "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

# yum-y remove mysql-server mysql mysql-libs

# yum-y remove php-mysql

# yum- y install yum-fastestmirror

# yum-y update

# 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 InstallMySQL56 ()

{

Echo "= = Install MySQL 5.6.22"

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

# mysql directory configuration

Groupadd mysql-g 512

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

Tar xvf / root/mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz

Mv / root/mysql-5.6.38-linux-glibc2.12-x86_64 / usr/local/mysql

Mkdir-p / data/mysql

Mkdir-p / log/mysql

Chown-R mysql:mysql / data/mysql

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

Chown-R mysql:mysql / log

# 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 & 1 | tee-a / root/mysql-install.log

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

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

Installation process:

[root@mysql ~] # sh mysql_auto_install.sh

=

A tool to auto-compile & install MySQL 5.6.38 on Redhat/CentOS Linux

=

= =

Please input the root password of mysql:

(Default password: mysqld):

= =

MySQL root password:mysqld

= =

= =

Install MySQL 5.6.38,Please input y

(Please input y, n): y

You will install MySQL 5.6.38

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

CentOS release 6.5 (Final)

Kernel\ r on an\ m

Linux mysql 2.6.32-431.el6.x86_64 # 1 SMP Fri Nov 22 03:15:09 UTC 2013 x86'64 GNU/Linux

Memory is: 1862 MB

Error: package mysql is not installed

Setenforce: SELinux is disabled

Mysql_auto_install.sh: line 243: CheckAndDownloadFiles: command not found

= = Install MySQL 5.6.22

Mysql-5.6.38-linux-glibc2.12-x86_64/share/polish/errmsg.sys

Mysql-5.6.38-linux-glibc2.12-x86_64/share/russian/errmsg.sys

Mysql-5.6.38-linux-glibc2.12-x86_64/share/german/errmsg.sys

Mysql-5.6.38-linux-glibc2.12-x86_64/share/spanish/errmsg.sys

Mysql-5.6.38-linux-glibc2.12-x86_64/share/italian/errmsg.sys

Mysql-5.6.38-linux-glibc2.12-x86_64/share/mysql_test_data_timezone.sql

Mysql-5.6.38-linux-glibc2.12-x86_64/share/norwegian/errmsg.sys

Mysql-5.6.38-linux-glibc2.12-x86_64/share/slovak/errmsg.sys

Mysql-5.6.38-linux-glibc2.12-x86_64/share/serbian/errmsg.sys

Mysql-5.6.38-linux-glibc2.12-x86_64/share/dutch/errmsg.sys

Mysql-5.6.38-linux-glibc2.12-x86_64/share/mysql_security_commands.sql

Mysql-5.6.38-linux-glibc2.12-x86_64/share/dictionary.txt

Mysql-5.6.38-linux-glibc2.12-x86_64/share/charsets/latin1.xml

Mysql-5.6.38-linux-glibc2.12-x86_64/share/charsets/Index.xml

Mysql-5.6.38-linux-glibc2.12-x86_64/share/charsets/latin2.xml

Mysql-5.6.38-linux-glibc2.12-x86_64/share/charsets/hp8.xml

Mysql-5.6.38-linux-glibc2.12-x86_64/share/charsets/latin7.xml

Mysql-5.6.38-linux-glibc2.12-x86_64/share/charsets/macroman.xml

Mysql-5.6.38-linux-glibc2.12-x86_64/share/charsets/ascii.xml

Mysql-5.6.38-linux-glibc2.12-x86_64/share/charsets/keybcs2.xml

Mysql-5.6.38-linux-glibc2.12-x86_64/share/charsets/greek.xml

Mysql-5.6.38-linux-glibc2.12-x86_64/share/charsets/hebrew.xml

Mysql-5.6.38-linux-glibc2.12-x86_64/share/charsets/cp1257.xml

Mysql-5.6.38-linux-glibc2.12-x86_64/share/charsets/swe7.xml

Mysql-5.6.38-linux-glibc2.12-x86_64/share/charsets/cp866.xml

Installing MySQL system tables...2017-11-11 00:44:28 0 [Note] Ignoring-- secure-file-priv value as server is running with-- bootstrap.

2017-11-11 00:44:28 0 [Note] / usr/local/mysql/bin/mysqld (mysqld 5.6.38-log) starting as process 3016.

OK

Filling help tables...2017-11-11 00:45:25 0 [Note] Ignoring-- secure-file-priv value as server is running with-- bootstrap.

2017-11-11 00:45:25 0 [Note] / usr/local/mysql/bin/mysqld (mysqld 5.6.38-log) starting as process 3040.

OK

To start mysqld at boot time you have to copy

Support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER!

To do so, start the server, then issue the following commands:

/ usr/local/mysql/bin/mysqladmin-u root password' new-password'

/ usr/local/mysql/bin/mysqladmin-u root-h 192.168.48.50 password' new-password'

Alternatively you can run:

/ usr/local/mysql/bin/mysql_secure_installation

Which will also give you the option of removing the test

Databases and anonymous user created by default. This is

Strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

Cd. ; / usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

Cd mysql-test; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

Http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as / usr/local/mysql/my.cnf and

Will be used by default by the server when you start it.

You may edit this file to change server settings

WARNING: Default config file / etc/my.cnf exists on the system

This file will be read by default by the MySQL server

If you do not want to use this, either remove it, or use the

-- defaults-file argument to mysqld_safe when starting the server

Starting MySQL.. SUCCESS!

Warning: Using a password on the command line interface can be insecure.

Warning: Using a password on the command line interface can be insecure.

Shutting down MySQL.. SUCCESS!

Starting MySQL.. SUCCESS!

= = MySQL 5.6.38 install completed=

^ Check install = =

Checking...

MySQL: OK

Install MySQL 5.6.38 completed! Enjoy it.

Transfer to: https://blog.csdn.net/gumengkai/article/details/78502131

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

Servers

Wechat

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

12
Report