mysql5 7一鍵部署指令碼

2021-10-25 03:12:29 字數 2758 閱讀 7354

shell指令碼,一鍵部署mysql5.7

#!

/bin/bash

read -p "請先確認將光碟掛載到/mnt目錄下,且mysql安裝包mysql-boost-5.7.20.tar.gz在/opt目錄下,y or n" start

[ $start ==

"n"]

&& exit 0

#關閉防火牆關閉核心防護

systemctl stop firewalld

systemctl disable firewalld

setenforce 0

echo 'selinux=disable

selinuxtype=targeted' >

/etc/selinux/config

yum -y install vim #超文字編輯器

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

useradd -s /sbin/nologin mysql

tar zvxf /opt/mysql-boost-

5.7.20

.tar.gz -c /opt

cd /opt/mysql-

5.7.20

/cmake -dcmake_install_prefix=

/usr/local/mysql -dmysql_unix_addr=

/usr/local/mysql/mysql.sock -dsysconfdir=

/etc -dsystemd_pid_dir=

/usr/local/mysql -ddefault_charset=utf8 -ddefault_collation=utf8_general_ci -dwith_innobase_storage_engine=

1-dwith_archive_storage_engine=

1-dwith_blackhole_storage_engine=

1-dwith_perfschema_storage_engine=

1-dmysql_datadir=

/usr/local/mysql/data -dwith_boost=boost -dwith_systemd=

1make -j2 && make install

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

echo '[client]

port =

3306

default

-character-set=utf8

socket =

/usr/local/mysql/mysql.sock

[mysql]

port =

3306

default

-character-set=utf8

socket =

/usr/local/mysql/mysql.sock

[mysqld]

user = mysql

basedir =

/usr/local/mysql

datadir =

/usr/local/mysql/data

port =

3306

character_set_server=utf8

pid-file =

/usr/local/mysql/mysqld.pid

socket =

/usr/local/mysql/mysql.sock

server-id =

1#skip-grant-tables

sql_mode=no_engine_substitution,strict_trans_tables,no_auto_create_user,no_auto_value_on_zero,no_zero_in_date,no_zero_date,error_for_division_by_zero,pipes_as_concat,ansi_quotes

' >

/etc/my.cnf

chown mysql:mysql /etc/my.cnf

echo 'path=/usr/local/mysql/bin:/usr/local/mysql/lib:$path'

>>

/etc/profile

echo 'export path'

>>

/etc/profile

source /etc/profile

cd /usr/local/mysql/

bin/mysqld --initialize-insecure --user=mysql --basedir=

/usr/local/mysql --datadir=

/usr/local/mysql/data

cp usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/

systemctl enable mysqld

systemctl start mysqld

systemctl status mysqld

netstat -anpt | grep 3306

[ $?

-eq 0

]&& echo "資料庫安裝完成,請及時登入修改密碼,初始密碼為空密碼"

一鍵部署lnmp指令碼

bin bash 關閉防火牆和selinux systemctl stop firewalld setenforce 0 echo 防火牆已關閉 echo 請手動檢查 systemctl disable firewalld dev null echo 1.nginx 安裝進行中 是否安裝常用工具 r...

關於CentOS7一鍵安裝mysql5 7演示

參照原博文centos7 安裝和配置mysql5.7 結合自己在網上搜尋的一些資料整合的一套安裝mysql並設定root密碼和資料庫遠端連線密碼的指令碼 部分指令碼 展示 bin bash 測試指令碼 輸出logo lingdulogo0.sh 檢測是否已安裝mysql service mysqld...

離線部署mysql5 7

檢查伺服器是否有rpm包 rpm qa grep mariadb如果有的話刪除即可 rpm e nodeps rpm名解壓tar包,並安裝 tar zxvf mysql 5.7.29 linux glibc2.12 x86 64.tar.gz mv mysql 5.7.29 linux glibc2...