MySQL 5 7 26版本指令碼安裝

2021-10-23 05:01:58 字數 3111 閱讀 3769

提取碼:g87h

#!/bin/bash

#描述:mysql5.7.26版本安裝指令碼

echo

"前提條件:將映象匯入系統,之後操作將以本地yum源的方式安裝依賴包"

echo

"把包放到/root/目錄下,然後執行安裝指令碼即可"

read -p "是否做好準備,開始安裝mysql(yes|no):" i

case

$iin

yes|y|y|yes)

echo

"---開始執行---"

mount /dev/cdrom /mnt

rm -rf /etc/yum.repos.d/*

cat>>/etc/yum.repos.d/yum.repo<<

eof[centos7]

name=centos7

baseurl=file:///mnt

enable=1

gpgcheck=0

eofecho

"***本地yum源搭建完成***"

yum -y remove boost-* &

>/dev/null

cd /root/

rpm -ivh mysql-community-5.7.26-1.el7.src.rpm

cd /root/rpmbuild/sources/

tar -jxvf boost_1_59_0.tar.bz2 -c /root/ &

>/dev/null

tar -zxvf mysql-5.7.26.tar.gz -c /root/ &

>/dev/null

yum -y remove mysql* &

>/dev/null

yum -y remove mariadb* &

>/dev/null

yum install -y cmake make gcc gcc-c++ bison ncurses ncurses-devel

echo

"---mysql相關依賴包安裝完成---"

groupadd mysql &

>/dev/null

useradd -m -s /sbin/nologin -r -g mysql mysql

mkdir -p /data/mysql/

chown -r mysql:mysql /data/mysql

cd /root/mysql-5.7.26

cmake -dcmake_install_prefix=/usr/local/mysql \

-dmysql_datadir=/data/mysql/data \

-dsysconfdir=/etc \

-dwith_myisam_storage_engine=1 \

-dwith_innobase_storage_engine=1 \

-dwith_memory_storage_engine=1 \

-dwith_readline=1 \

-dmysql_unix_addr=/usr/local/mysql/mysql.sock \

-dmysql_tcp_port=3306 \

-denabled_local_infile=1 \

-dwith_partition_storage_engine=1 \

-dextra_charsets=all \

-ddefault_charset=utf8 \

-ddefault_collation=utf8_general_ci \

-ddownload_boost=1 \

-dwith_boost=/root/boost_1_59_0 &

>/dev/nullif[

$? -eq 0 ]

;then

echo

"===cmake預編譯成功,開始安裝mysql==="

else

echo

"===cmake預編譯失敗,請檢查工具版本==="

exit 1

fimake -j 6 ;

make

install

&>/dev/null

echo

"---mysql安裝完成---"

chown -r mysql:mysql /usr/local/mysql/

mv /etc/my.cnf /etc/my.cnf.bak

cat>>/etc/my.cnf<<

eof[mysqld]

basedir=/usr/local/mysql

datadir=/data/mysql/data

port=3306

socket=/usr/local/mysql/mysql.sock

symbolic-links=0

character-set-server=utf8

log-error=/data/mysql/log/mysqld.log

pid-file=/usr/local/mysql/mysqld.pid

eofcp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

chkconfig --add mysqld

chkconfig mysqld on

/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data

/etc/init.d/mysqld start

ln -s /usr/local/mysql/bin/* /usr/local/bin/

echo

"---mysql配置完成,直接輸入mysql即可登入資料庫---";;

no|no|n|n)

echo

"---正在退出---"

exit 2;;

*)echo

"---輸入錯誤,正在退出---"

exit 3

esac

Mysql 5 7 26安裝小記

按照依賴完成安裝後,需要檢視 var log mysql.log 檔案,找到臨時密碼登入mysql 登入mysql後需要即刻修改密碼 mysql u root p 然後輸入密碼進入mysql use mysql alter user user identified by 新密碼 密碼有複雜度要求的,...

mysql5 7 26安裝步驟

2.為my.ini新增內容如下 client port 3306 default character set utf8 mysqld 設定為自己mysql的安裝目錄 basedir d mysql 設定為mysql的資料目錄 datadir d mysql data character set se...

MySQL 5 7 26安裝部署

mysql 5.7.26 二進位制版本安裝 root db01 mkdir p server tools root db01 cd server tools root db01 tools ls mysql 5.7.26 linux glibc2.12 x86 64.tar.gz 2 解壓軟體 4 ...