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

Automatic installation of Mysql5.6- script implementation

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

Share

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

New features of Mysql5.6: 1. Optimizer improvement: mainly reflected in the index condition pushdown and multi-range read data, can reduce overload.

2 improvement of InnoDB: the MySQL InnoDB storage engine team mainly provides NoSQL access interface, which can directly access InnoDB tables through Memcached API.

3, better replication: improved data integrity and high availability and performance.

Installation environment, a Centos6.5 recommended binary installation. This article has been tested and has no problem as a production library. Each company has different needs and can be changed slightly. Mysql-5.6.25-linux-glibc2.5-x86_64.tar.gz is used in this article.

If the version is different, you can change the script's 109th and 110th lines to replace the mysql installation package name.

two。 To start the installation, just put the installation package in root and the script under root.

The script is as follows:

[root@centos4 ~] # cat install-mysql.sh

# binary automatic installation database script root password MANAGER 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:zhangbin

#

#! / 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.25 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 "= ="

Isinstallmysql56= "n"

Echo "Install MySQL 5.6.25 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.25"

Isinstallmysql56= "y"

*)

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

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.25-linux-glibc2.5-x86_64.tar.gz

Mv / root/mysql-5.6.25-linux-glibc2.5-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

3. After execution, enter:

[root@centos4 ~] # source / etc/profile

Start:

[root@centos4 ~] # / etc/init.d/mysqld start

4. Solve the problem of unable to connect to the database remotely 1045 access denied for user 'root'@localhhost' using password yes

5. Execute in mysql

Execute from the mysql command line

SET PASSWORD FOR'root'@'localhost' = PASSWORD ('123456')

GRANT ALL PRIVILEGES ON *. * TO 'root' @'% 'IDENTIFIED BY' 123456 'WITH GRANT OPTION

Flush privileges

If the above methods do not work, then:

Use mysql

UPDATE user SETPassword=PASSWORD ('123456') where USER='root'

Flush privileges

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