Linux运维_Bash脚本_构建安装MySQL-8.0.18

Linux运维_Bash脚本_构建安装MySQL-8.0.18

Bash (Bourne Again Shell) 是一个解释器,负责处理 Unix 系统命令行上的命令。它是由 Brian Fox 编写的免费软件,并于 1989 年发布的免费软件,作为 Sh (Bourne Shell) 的替代品。

您可以在 Linux 和 MacOS 机器上使用 Bash,甚至可以通过适用于 Linux 的 Windows 子系统在 Windows 10 机器上使用。

使用方法

  • 下载源码包:

zlib-1.2.13.tar.gz

libunwind-1.6.2.tar.gz

openssl-1.1.1g.tar.gz

ncurses-6.4.tar.gz

mysql-boost-8.0.18.tar.gz

  • 放于指定路径:

这里 Bash Shell 脚本的全局变量 STORAGE 指定的存放源码包的路径 /home/goufeng 可进行修改。

  • 执行 Bash Shell 脚本:

输入 /[路径名]/[脚本名].sh 即可进行自动编译部署,过程中提示输入 (y/n) 输入 y 则进行下一步,这样分阶段确认的原因是为了确保能够看到上一个源码编译结果中可能的错误和提示。

完整脚本

#! /bin/bash
# Create By GF 2023-03-20 10:31# --------------------------------------------------
# Install First: 
# * GNU-Tools (Contains: pkg-config, m4, autoconf, automake, libtool, gettext, flex, bison, libiconv, make)
# * GCC >= 5.3
# * CMake >= 3.8.0# ------------------- Dependency -------------------
# Need File: zlib-1.2.13.tar.gz
# Need File: libunwind-1.6.2.tar.gz
# Need File: openssl-1.1.1g.tar.gz
# Need File: ncurses-6.4.tar.gz
# -------- MySQL - 8.0.18 (Contains Boost) ---------
# Need File: mysql-boost-8.0.18.tar.gz# ##################################################
STORAGE=/home/goufeng# ############################################ Dependency ############################################# Function: 编译安装(Compile Install) zlib-1.2.13
# ##################################################
function Compile_Install_zlib_1_2_13() {if [[ ! -f "/usr/include/zlib.h" && ! -f "/usr/local/include/zlib.h" && ! -d "/opt/zlib-1.2.13" ]]; thenlocal VERIFYlocal STEP_UNZIPPED=0local STEP_CONFIGURED=0local STEP_INSTALLED=0# ------------------------------------------read -p "[Confirm] Compile and Install ( zlib-1.2.13 )? (y/n)>" VERIFYif [[ "$VERIFY" != "y" ]]; then exit 1; fi# ------------------------------------------tar -zxvf $STORAGE/zlib-1.2.13.tar.gz && STEP_UNZIPPED=1# ------------------------------------------cd $STORAGE/zlib-1.2.13 && ./configure --prefix=/opt/zlib-1.2.13 && STEP_CONFIGURED=1# ------------------------------------------make && make install && STEP_INSTALLED=1# ------------------------------------------if [[ $STEP_INSTALLED == 1 ]]; thenif [[ ! -d "/opt/lib" ]]; then mkdir /opt/lib; fiif [[ ! -d "/opt/lib/pkgconfig" ]]; then mkdir /opt/lib/pkgconfig; fi# ......................................rsync -av /opt/zlib-1.2.13/include/ /usr/local/include/# ......................................rsync -av /opt/zlib-1.2.13/lib/ /usr/local/lib/# ......................................cp -f /opt/zlib-1.2.13/lib/pkgconfig/zlib.pc /opt/lib/pkgconfig/fi# ------------------------------------------cd $STORAGE && rm -rf $STORAGE/zlib-1.2.13 && return 0elseecho "[Caution] Program: ( /usr/include/zlib.h or /usr/local/include/zlib.h or /opt/zlib-1.2.13 ) Already Exists."# ------------------------------------------return 0fi
}# Function: 编译安装(Compile Install) libunwind-1.6.2
# ##################################################
function Compile_Install_libunwind_1_6_2() {if [[ ! -d "/opt/libunwind-1.6.2" ]]; thenlocal VERIFYlocal STEP_UNZIPPED=0local STEP_CONFIGURED=0local STEP_INSTALLED=0# ------------------------------------------read -p "[Confirm] Compile and Install ( libunwind-1.6.2 )? (y/n)>" VERIFYif [[ "$VERIFY" != "y" ]]; then exit 1; fi# ------------------------------------------tar -zxvf $STORAGE/libunwind-1.6.2.tar.gz && STEP_UNZIPPED=1# ------------------------------------------cd $STORAGE/libunwind-1.6.2 && ./configure --prefix=/opt/libunwind-1.6.2 && STEP_CONFIGURED=1# ------------------------------------------make && make install && STEP_INSTALLED=1# ------------------------------------------if [[ $STEP_INSTALLED == 1 ]]; thenif [[ ! -d "/opt/lib" ]]; then mkdir /opt/lib; fiif [[ ! -d "/opt/lib/pkgconfig" ]]; then mkdir /opt/lib/pkgconfig; fi# ......................................ln -sf /opt/libunwind-1.6.2/bin/xmlwf /usr/local/bin/# ......................................rsync -av /opt/libunwind-1.6.2/include/ /usr/local/include/# ......................................rsync -av /opt/libunwind-1.6.2/lib/ /usr/local/lib/# ......................................cp -vf /opt/libunwind-1.6.2/lib/pkgconfig/*.pc /opt/lib/pkgconfig/fi# ------------------------------------------# Ubuntu Linux Proprietary Command.ldconfig# ------------------------------------------# FreeBSD Unix Proprietary Command./etc/rc.d/ldconfig restart# ------------------------------------------cd $STORAGE && rm -rf $STORAGE/libunwind-1.6.2 && return 0elseecho "[Caution] Path: ( /opt/libunwind-1.6.2 ) Already Exists."# ------------------------------------------return 0fi
}# Function: 编译安装(Compile Install) openssl-1.1.1g
# ##################################################
function Compile_Install_openssl_1_1_1g() {if [[ ! -d "/opt/openssl-1.1.1g" ]]; thenlocal VERIFYlocal STEP_UNZIPPED=0local STEP_CONFIGURED=0local STEP_INSTALLED=0# ------------------------------------------read -p "[Confirm] Compile and Install ( openssl-1.1.1g )? (y/n)>" VERIFYif [[ "$VERIFY" != "y" ]]; then exit 1; fi# ------------------------------------------tar -zxvf $STORAGE/openssl-1.1.1g.tar.gz && STEP_UNZIPPED=1# ------------------------------------------cd $STORAGE/openssl-1.1.1g && ./config --prefix=/opt/openssl-1.1.1g \--openssldir=/opt/openssl-1.1.1g/ssl \--shared \zlib && \STEP_CONFIGURED=1# ------------------------------------------make && make install && STEP_INSTALLED=1# ------------------------------------------if [[ $STEP_INSTALLED == 1 ]]; thenif [[ ! -d "/opt/lib" ]]; then mkdir /opt/lib; fiif [[ ! -d "/opt/lib/pkgconfig" ]]; then mkdir /opt/lib/pkgconfig; fi# ......................................# 注意: 避免与系统原有的 "openssl" 发生冲突, 未将 "openssl-1.1.1g" 的二进制 bin 文件发送到 PATH 路径。# Caution: To avoid conflicts with the original "openssl" in the system, the binary file of "openssl-1.1.1g" was not sent to the PATH path.# ......................................# Skip # ln -sf /opt/openssl-1.1.1g/bin/* /usr/local/bin/# ......................................# Skip # rsync -av /opt/openssl-1.1.1g/include/ /usr/local/include/# ......................................# Skip # rsync -av /opt/openssl-1.1.1g/lib/ /usr/local/lib/# ......................................cp -f /opt/openssl-1.1.1g/lib/pkgconfig/libcrypto.pc /opt/lib/pkgconfig/cp -f /opt/openssl-1.1.1g/lib/pkgconfig/libssl.pc    /opt/lib/pkgconfig/cp -f /opt/openssl-1.1.1g/lib/pkgconfig/openssl.pc   /opt/lib/pkgconfig/fi# ------------------------------------------cd $STORAGE && rm -rf $STORAGE/openssl-1.1.1g && return 0elseecho "[Caution] Path: ( /opt/openssl-1.1.1g ) Already Exists."# ------------------------------------------return 0fi
}# Function: 编译安装(Compile Install) ncurses-6.4
# ##################################################
function Compile_Install_ncurses_6_4() {# ncurses (new curses) 是一套编程库,它提供了一系列的函数以便使用者调用它们去生成基于文本的用户界面。# ncurses 名字中的n意味着 "new", 因为它是 curses 的自由软件版本。由于 AT&T "臭名昭著" 的版权政策, 人们不得不在后来用 ncurses 去代替它。# ncurses 是 GNU 计划的一部分, 但它却是少数几个不使用 GNU GPL 或 LGPL 授权的 GNU 软件之一。# 其实我们对 ncurses 本身并不陌生,以下几款大名鼎鼎的软件都用到过 ncurses:#     * vim#     * emacs#     * lynx#     * screen# 作为嵌入式驱动开发工程师, Linux 内核的配置也离不开 ncurses 库的使用。if [[ ! -d "/opt/ncurses-6.4" ]]; thenlocal VERIFYlocal STEP_UNZIPPED=0local STEP_CONFIGURED=0local STEP_INSTALLED=0# ------------------------------------------echo "[Confirm] Compile and Install ( ncurses-6.4 )? (y/n)"# ..........................................read VERIFY# ..........................................if [[ $VERIFY != "y" ]]; then exit 1; fi# ------------------------------------------tar -zxvf $STORAGE/ncurses-6.4.tar.gz && STEP_UNZIPPED=1# ------------------------------------------cd $STORAGE/ncurses-6.4 && ./configure --prefix=/opt/ncurses-6.4 \--enable-pc-files \--enable-shared \--with-libtool && \STEP_CONFIGURED=1# ------------------------------------------make && make install && STEP_INSTALLED=1# ------------------------------------------if [[ $STEP_INSTALLED == 1 ]]; thenif [[ ! -d "/usr/local/lib/terminfo" ]]; then mkdir /usr/local/lib/terminfo; fi# ......................................if [[ ! -d "/opt/lib" ]]; then mkdir /opt/lib; fiif [[ ! -d "/opt/lib/pkgconfig" ]]; then mkdir /opt/lib/pkgconfig; fi# ......................................# Skip # ln -sf /opt/ncurses-6.4/bin/* /usr/local/bin/# ......................................rsync -av /opt/ncurses-6.4/include/ /usr/local/include/# ......................................cp -vf /opt/ncurses-6.4/include/ncurses/*.h /usr/local/include/# ......................................rsync -av /opt/ncurses-6.4/lib/ /usr/local/lib/# ......................................rsync -av /opt/ncurses-6.4/share/terminfo/ /usr/local/lib/terminfo/# ......................................cp -vf /opt/ncurses-6.4/lib/pkgconfig/*.pc /opt/lib/pkgconfig/fi# ------------------------------------------# Ubuntu Linux Proprietary Command.ldconfig# ------------------------------------------# FreeBSD Unix Proprietary Command./etc/rc.d/ldconfig restart# ------------------------------------------cd $STORAGE && rm -rf $STORAGE/ncurses-6.4 && return 0elseecho "[Caution] Path: ( /opt/ncurses-6.4 ) Already Exists."# ------------------------------------------return 0fi
}# ################################# MySQL - 8.0.18 (Contains Boost) ################################### Function: 构建安装(Build Install) MySQL-8.0.18 (Contains Boost)
# ##################################################
function Build_Install_MySQL_8_0_18_Contains_Boost() {# Warning: Need GCC 5.3 or newer (GCC > 5.3).# ..............................................# Warning: If it is under 5.7 and includes 5.7, still using utf8, cannot add -DDEFAULT_CHARSET=utf8mb4# ..............................................# MySQL 8.0.18 "my.cnf" Location                    : /opt/mysql8-data/conf/my.cnf (Need: chmod 644)# MySQL 8.0.18 Initialize                           : mysqld --defaults-file=/opt/mysql8-data/conf/my.cnf --initialize --user=mysql# MySQL 8.0.18 Temporary Password                   : cat /opt/mysql8-data/log/error_log/mysql-error.log | grep password# Log in to MySQL 8.0.18                            : mysql -uroot -pujbbqC?A+38g# MySQL 8.0.18 Password Modification                : mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '12345678';if [[ ! -d "/opt/mysql-8.0.18" ]]; thenlocal VERIFYlocal STEP_UNZIPPED=0local STEP_CREATED=0local STEP_BUILDED=0local STEP_INSTALLED=0local GROUP_NAME="None"local USER_NAME="None"# ------------------------------------------read -p "[Confirm] Build and Install ( mysql-8.0.18 )? (y/n)>" VERIFYif [[ "$VERIFY" != "y" ]]; then exit 1; fi# ------------------------------------------tar -zxvf $STORAGE/mysql-boost-8.0.18.tar.gz && STEP_UNZIPPED=1# ------------------------------------------# Clang-11 Error Handling:# ..........................................# * Problem: /home/goufeng/mysql-8.0.18/plugin/group_replication/src/plugin.cc:548:35: error: cannot initialize return object of type 'bool' with an rvalue of type 'nullptr_t'#                                              NULL, NULL, NULL, NULL, NULL, NULL, NULL,#                                              ^~~~#            /home/goufeng/mysql-8.0.18/plugin/group_replication/src/plugin.cc:549:41: error: cannot initialize return object of type 'bool' with an rvalue of type 'nullptr_t'#                                              NULL, NULL, DEFAULT_THREAD_PRIORITY, 1, false,#                                                    ^~~~#   - Solve: Just replace NULL with false (只需将 NULL 替换为 false)。# ..........................................# Skip # sed -i ".bak" "548 s/NULL, NULL, NULL, NULL, NULL, NULL, NULL,/false, NULL, NULL, NULL, NULL, NULL, NULL,/" $STORAGE/mysql-8.0.18/plugin/group_replication/src/plugin.cc# Skip # sed -i ".bak" "549 s/NULL, NULL, DEFAULT_THREAD_PRIORITY, 1, false,/NULL, false, DEFAULT_THREAD_PRIORITY, 1, false,/" $STORAGE/mysql-8.0.18/plugin/group_replication/src/plugin.cc# ..........................................# * Problem: /home/goufeng/mysql-8.0.18/plugin/group_replication/src/recovery_state_transfer.cc:605:52: error: cannot initialize return object of type 'bool' with an rvalue of type 'nullptr_t'#                  const_cast<char *>("<NULL>"), 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL,#                                                               ^~~~#            /home/goufeng/mysql-8.0.18/plugin/group_replication/src/recovery_state_transfer.cc:606:25: error: cannot initialize return object of type 'bool' with an rvalue of type 'nullptr_t'#                  NULL, NULL, NULL, NULL, DEFAULT_THREAD_PRIORITY, 1, false, NULL, false,#                                    ^~~~#   - Solve: Just replace NULL with false (只需将 NULL 替换为 false)。# ..........................................# Skip # sed -i ".bak" "605 s/0, NULL, NULL, NULL, NULL, NULL, NULL, NULL,/0, NULL, NULL, false, NULL, NULL, NULL, NULL,/" $STORAGE/mysql-8.0.18/plugin/group_replication/src/recovery_state_transfer.cc# Skip # sed -i ".bak" "606 s/NULL, NULL, NULL, NULL, DEFAULT_THREAD_PRIORITY,/NULL, NULL, NULL, false, DEFAULT_THREAD_PRIORITY,/" $STORAGE/mysql-8.0.18/plugin/group_replication/src/recovery_state_transfer.cc# ------------------------------------------mkdir $STORAGE/mysql-8.0.18/build && STEP_CREATED=1# ------------------------------------------# Create Group and User For MySQL.GROUP_NAME=`cat /etc/group | grep -o "mysql"`# ..........................................if [[ -z "$GROUP_NAME" ]]; then addgroup --system mysql; fi# ..........................................USER_NAME=`cat /etc/passwd | grep -o "mysql"`# ..........................................# The difference between "adduser" and "useradd":#     "adduser" is not a standard Linux command, it is essentially a Perl script.#     Calling the "useradd" command in the background makes this advanced utility more efficient when creating users in Linux.#     "useradd" provides options for creating a home directory, setting passwords, and other parameters.# ..........................................# useradd Option Description:#     -c: Add note text and save it in the note column of passwd.#     -d: Specify the user's home directory when logging in, replace the system default value of /home/<username>.#     -g: Specify the group to which the user belongs. The value can be either a group name or a GID. The user group must already exist, with a default value of 100, which is users.#     -s: Specify the shell that the user will use after logging in. The default value is /bin/bash.#     -u: Specify the user ID number. This value must be unique within the system. 0~499 is reserved for the system user account by default, so the value must be greater than 499.#     -m: Automatically establish the user's login directory.#     -M: Do not automatically establish a user's login directory# ..........................................if [[ -z "$USER_NAME" ]]; then useradd mysql -s /sbin/nologin -g mysql -M; fi# ------------------------------------------# Create The Required Directory For MySQL.if [[ ! -d "/opt/mysql8-data" ]]; thenmkdir -p /opt/mysql8-data/runmkdir -p /opt/mysql8-data/datamkdir -p /opt/mysql8-data/tmpmkdir -p /opt/mysql8-data/confmkdir -p /opt/mysql8-data/log/bin_logmkdir -p /opt/mysql8-data/log/error_logmkdir -p /opt/mysql8-data/log/query_logmkdir -p /opt/mysql8-data/log/general_logmkdir -p /opt/mysql8-data/log/innodb_tsmkdir -p /opt/mysql8-data/log/undo_spacemkdir -p /opt/mysql8-data/log/innodb_logfi# ------------------------------------------# Granting mysql8-data Permissions To MySQL Users.chown -R mysql:mysql /opt/mysql8-data# ------------------------------------------# *  Option: -DCMAKE_BUILD_TYPE=Release: Specify a buildtype suitable for stable releases of the package, as the default may produce unoptimized binaries.#                                        指定一个适用于包的稳定版本的构建类型, 因为默认情况下可能会生成未优化的二进制文件。# ..........................................# *  Option: -DWITH_BOOST=boost: Specify the path to Boost, such as "-DWITH_BOOST=/home/[UserName]/boost/boost_1_70_0",  If installing using the mysql boost x.x.x integration package, then "-DWITH_BOOST=boost" or "-DWITH_BOOST=../boost".#                                指定 Boost 的路径, 如: "-DWITH_BOOST=/home/[UserName]/boost/boost_1_70_0", 若使用 mysql-boost-x.x.x 集成包安装则 "-DWITH_BOOST=boost" 或者 "-DWITH_BOOST=../boost"。# ..........................................cd $STORAGE/mysql-8.0.18/build && cmake ../ -G "Unix Makefiles" \-DCMAKE_INSTALL_PREFIX=/opt/mysql-8.0.18 \-DWITH_BOOST=../boost \-DMYSQL_DATADIR=/opt/mysql8-data/data \-DMYSQL_UNIX_ADDR=/opt/mysql8-data/run/mysql.sock \-DSYSCONFDIR=/opt/mysql8-data/conf \-DCMAKE_C_COMPILER=/usr/bin/gcc \-DCMAKE_CXX_COMPILER=/usr/bin/g++ \-DMYSQL_TCP_PORT=3306 \-DCMAKE_BUILD_TYPE=Release \-DCOMPILATION_COMMENT="GF Self Use Edition" \-DDEFAULT_CHARSET=utf8mb4 \-DDEFAULT_COLLATION=utf8mb4_general_ci \-DEXTRA_CHARSETS=all \-DENABLED_LOCAL_INFILE=ON \-DWITH_INNODB_MEMCACHED=ON \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_FEDERATED_STORAGE_ENGINE=1 \-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \-DWITH_ARCHIVE_STORAGE_ENGINE=1 \-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \-DFORCE_INSOURCE_BUILD=1 \-DWITH_READLINE=1 \-DWITH_SSL=system \-DWITH_ZLIB=system && \STEP_BUILDED=1# ------------------------------------------make && make install && STEP_INSTALLED=1# ------------------------------------------if [[ $STEP_INSTALLED == 1 ]]; thenif [[ ! -d "/opt/lib" ]]; then mkdir /opt/lib; fiif [[ ! -d "/opt/lib/pkgconfig" ]]; then mkdir /opt/lib/pkgconfig; fi# ......................................ln -svf /opt/mysql-8.0.18/bin/* /usr/local/bin/# ......................................# Skip # rsync -av /opt/mysql-8.0.18/include/ /usr/local/include/# ......................................# Skip # rsync -av /opt/mysql-8.0.18/lib/ /usr/local/lib/# ......................................cp -vf /opt/mysql-8.0.18/lib/pkgconfig/*.pc /opt/lib/pkgconfig/fi# ------------------------------------------# Create MySQL Configure File: "my.cnf".if [[ $STEP_INSTALLED == 1 && ! -f "/opt/mysql8-data/conf/my.cnf" ]]; thentouch /opt/mysql8-data/conf/my.cnf# ......................................echo ""                                      >> /opt/mysql8-data/conf/my.cnfecho "[mysqld]"                              >> /opt/mysql8-data/conf/my.cnfecho ""                                      >> /opt/mysql8-data/conf/my.cnfecho "# Class: Database Server"              >> /opt/mysql8-data/conf/my.cnfecho "port=3306"                             >> /opt/mysql8-data/conf/my.cnfecho "user=mysql"                            >> /opt/mysql8-data/conf/my.cnfecho ""                                      >> /opt/mysql8-data/conf/my.cnfecho "# Class: Database Directory"           >> /opt/mysql8-data/conf/my.cnfecho "basedir=/opt/mysql-8.0.18"             >> /opt/mysql8-data/conf/my.cnfecho "datadir=/opt/mysql8-data/data"         >> /opt/mysql8-data/conf/my.cnfecho ""                                      >> /opt/mysql8-data/conf/my.cnfecho "# Class: Database Storage"             >> /opt/mysql8-data/conf/my.cnfecho "default-storage-engine=INNODB"         >> /opt/mysql8-data/conf/my.cnfecho ""                                      >> /opt/mysql8-data/conf/my.cnfecho "# Class: Database Connection"          >> /opt/mysql8-data/conf/my.cnfecho "max_connections=10000"                 >> /opt/mysql8-data/conf/my.cnfecho "max_connect_errors=10"                 >> /opt/mysql8-data/conf/my.cnfecho ""                                      >> /opt/mysql8-data/conf/my.cnfecho "# Class: Database Character"           >> /opt/mysql8-data/conf/my.cnfecho "character-set-server=utf8mb4"          >> /opt/mysql8-data/conf/my.cnfecho "lower_case_table_names=1"              >> /opt/mysql8-data/conf/my.cnfecho ""                                      >> /opt/mysql8-data/conf/my.cnfecho "[mysql]"                               >> /opt/mysql8-data/conf/my.cnfecho ""                                      >> /opt/mysql8-data/conf/my.cnfecho "# Class: MySQL Command Line Character" >> /opt/mysql8-data/conf/my.cnfecho "default-character-set=utf8mb4"         >> /opt/mysql8-data/conf/my.cnfecho ""                                      >> /opt/mysql8-data/conf/my.cnfecho "[client]"                              >> /opt/mysql8-data/conf/my.cnfecho ""                                      >> /opt/mysql8-data/conf/my.cnfecho "# Class: Client Connection"            >> /opt/mysql8-data/conf/my.cnfecho "port=3306"                             >> /opt/mysql8-data/conf/my.cnfecho ""                                      >> /opt/mysql8-data/conf/my.cnfecho "# Class: Client Character"             >> /opt/mysql8-data/conf/my.cnfecho "default-character-set=utf8mb4"         >> /opt/mysql8-data/conf/my.cnfecho ""                                      >> /opt/mysql8-data/conf/my.cnffi# ------------------------------------------# Copy MySQL Startup File: "mysqld".if   [[ $STEP_INSTALLED == 1 && -d "/etc/rc.d" ]]; thencp -v /opt/mysql-8.0.18/support-files/mysql.server /etc/rc.d/mysqld# ......................................sed -r -i ".bak" "s#^basedir\=.*#basedir\=/opt/mysql-8.0.18#" /etc/rc.d/mysqldsed -r -i ".bak" "s#^datadir\=.*#datadir\=/opt/mysql8-data/data#" /etc/rc.d/mysqld# ......................................chmod 700 /etc/rc.d/mysqld# ..........................................elif [[ $STEP_INSTALLED == 1 && -d "/etc/init.d" ]]; thencp -v /opt/mysql-8.0.18/support-files/mysql.server /etc/init.d/mysqld# ......................................sed -r -i "s#^basedir\=.*#basedir\=/opt/mysql-8.0.18#" /etc/init.d/mysqldsed -r -i "s#^datadir\=.*#datadir\=/opt/mysql8-data/data#" /etc/init.d/mysqld# ......................................chmod 700 /etc/init.d/mysqldfi# ------------------------------------------cd $STORAGE && rm -rf $STORAGE/mysql-8.0.18 && return 0elseecho "[Caution] Path: ( /opt/mysql-8.0.18 ) Already Exists."# ------------------------------------------return 0fi
}function main() {# ----------------- Dependency -----------------Compile_Install_zlib_1_2_13Compile_Install_libunwind_1_6_2Compile_Install_openssl_1_1_1gCompile_Install_ncurses_6_4# ------ MySQL - 8.0.18 (Contains Boost) -------Build_Install_MySQL_8_0_18_Contains_Boost
}main

总结

以上就是关于 Linux运维 Bash脚本 构建安装MySQL-8.0.18 的全部内容。

更多内容可以访问我的代码仓库:

https://gitee.com/goufeng928/public

https://github.com/goufeng928/public

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/764168.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

鸿蒙Harmony应用开发—ArkTS-@AnimatableExtend装饰器:定义可动画属性

AnimatableExtend装饰器用于自定义可动画的属性方法&#xff0c;在这个属性方法中修改组件不可动画的属性。在动画执行过程时&#xff0c;通过逐帧回调函数修改不可动画属性值&#xff0c;让不可动画属性也能实现动画效果。 可动画属性&#xff1a;如果一个属性方法在animation…

【C语言基础篇】内存处理函数(二)memove的介绍及模拟实现

个人主页&#xff1a; 倔强的石头的博客 系列专栏 &#xff1a;C语言指南 C语言刷题系列 待完善补充

无插件网页视频播放器,支持图像绘制(包含方格子、方框等),支持音视频播放、支持录像截图,提供源码下载

前言 本播放器内部采用jessibuca插件接口&#xff0c;支持录像、截图、音视频播放等功能。播放器播放基于ws流&#xff0c;图像绘制操作&#xff1a;1&#xff09;支持绘制方格子&#xff0c;用于监控移动检测画框&#xff1b;2&#xff09;支持绘制不透明方框&#xff0c;用于…

macOS下Java应用的打包和安装程序制作

文章目录 macOS应用程序结构Java应用打包JavaAppLauncherjpackage其它相关JDK命令附录JavaAppLauncher源码链接macOS应用程序结构 macOS通常以dmg或pkg作为软件发行包,安装到/Applications下后,结构比较统一。 info.plist里的CFBundleExecutable字段可以指定入口,如果不指定…

基于JavaWeb+BS架构+SpringBoot+Vue+O2O生鲜食品订购小程序系统的设计和实现

基于JavaWebBS架构SpringBootVueO2O生鲜食品订购小程序系统的设计和实现 文末获取源码Lun文目录前言主要技术系统设计功能截图 文末获取源码 Lun文目录 目 录 摘 要 I Abstract II 1 绪 论 1 1.1课题研究背景及意义 1 1.2研究现状 1 1.3本论文的主要论文结构 3 2系统相关技术…

【工具使用】VScode如何设置中文环境

操作步骤 1.1 安装中文插件 1.2 设置为中文&#xff0c;然后重启 按照插件的使用方法介绍设置中文&#xff1a; 按下“CtrlShiftP”组合键以显示“命令面板”&#xff1a; 输入“dispaly”&#xff0c;选择“Configure Display Language”&#xff1a; 选择“中文简体” …

使用Python和OpenFOAM进行流体力学模拟的基础示例

流体力学模拟通常涉及复杂的数学方程和数值方法&#xff0c;例如计算流体动力学(CFD)。OpenFOAM是一个开源的CFD工具箱&#xff0c;它使用C编写&#xff0c;但可以通过Python脚本进行自动化和定制。 以下是一个简单的示例&#xff0c;展示如何使用Python和OpenFOAM进行流体力学…

【练习】双指针算法思想

&#x1f3a5; 个人主页&#xff1a;Dikz12&#x1f525;个人专栏&#xff1a;Java算法&#x1f4d5;格言&#xff1a;那些在暗处执拗生长的花&#xff0c;终有一日会馥郁传香欢迎大家&#x1f44d;点赞✍评论⭐收藏 目录 1. 移动零 1.1 题目描述 1.2 讲解算法原理 1.3 编…

请解释 VB.NET 中的命名空间(Namespace)以及它们的作用

请解释 VB.NET 中的命名空间&#xff08;Namespace&#xff09;以及它们的作用 在VB.NET中&#xff0c;命名空间&#xff08;Namespace&#xff09;是一种用于组织和管理代码的机制。命名空间允许开发人员将相关的类、结构、接口和其他类型组织在一起&#xff0c;以便更好地管…

代码随想录 动态规划-子序列问题-子序列(连续)

目录 674.最长连续递增序列 718.最长重复子数组 53.最大子数组和 674.最长连续递增序列 674. 最长连续递增序列 简单 给定一个未经排序的整数数组&#xff0c;找到最长且 连续递增的子序列&#xff0c;并返回该序列的长度。 连续递增的子序列 可以由两个下标 l 和 r&…

数字孪生底层技术框架

数字孪生是一种将现实世界中的物理实体、过程或系统数字化并映射到计算机模型中的方法。它在数学建模与仿真方面具有重要作用&#xff0c;为了实现数字孪生&#xff0c;以下是一些底层技术框架和方法&#xff0c;希望对大家有所帮助。北京木奇移动技术有限公司&#xff0c;专业…

【高并发服务器 02】——线程池与IO多路复用

线程池复习 线程池的好处&#xff1a;所有的池都是为了事先把资源准备好&#xff0c;在后续用的时候可以更加方便的拿到这个资源——不用去申请、释放资源 什么时候用线程池&#xff1f; IO&事务并发较高&#xff1a;人在杭州&#xff0c;但是数据库在北京&#xff0c;想要…

企业网络基础设施物理安全面临全新挑战

企业网络基础设施的物理安全是确保业务连续性和数据完整性的关键组成部分。随着技术的发展和环境的变化&#xff0c;这些基础设施面临着新的挑战。以下是一些主要的挑战和的解决方案 一、机房、仓库、档案馆物理安全事件频发的挑战&#xff1a; 1.电力安全事件&#xff1a;市…

AI智能分析网关V4在养老院视频智能监控场景中的应用

随着科技的快速发展&#xff0c;智能监控技术已经广泛应用于各个领域&#xff0c;尤其在养老院这一特定场景中&#xff0c;智能监控方案更是发挥着不可或缺的作用。尤其是伴随着社会老龄化趋势的加剧&#xff0c;养老院的安全管理问题也日益凸显。为了确保老人的生活安全&#…

没有磁盘整列下的多机分布式存储:使用rysnc+多服务器文件/文件夹内容同步

目录 0.为什么要定时同步 1.程序安装 2.文件夹设置rsync使用 3.使用cron进行定时任务 0.为什么要定时同步 作为科研党&#xff0c;实验室有多个服务器&#xff0c;但是都是分批买的没有上磁盘整列&#xff0c;所以一个服务器上跑的东西并不能同步&#xff0c;有时候挂任务要…

第十二届蓝桥杯省赛CC++ 研究生组-异或数列

solution1&#xff08;通过0%&#xff09; 没看懂怎么是必胜或必败局面(˚ ˃̣̣̥᷄⌓˂̣̣̥᷅ ) #include<iostream> typedef long long ll; const int maxn 200010; ll x[maxn]; int main(){int t, n;ll a, b, turn;scanf("%d", &t);while(t--){…

防火墙(讲解)

目录 1.防火墙是什么? 2.防火墙设备 3.防火墙功能 1)出色的控制能力&#xff0c;过滤掉不安全服务 2)过滤非法用户和访问特殊站点 3)它能够对网络存取和访问进行监控审计 4.防火墙的局限 (1)防火墙有可能是可以绕过的 (2)防火墙不能防止内部出卖性攻击或者内部误操作…

vue的优缺点有那些 组件常用的有那些?

优点&#xff1a; 组件化开发&#xff0c;提升效率&#xff0c;方便复用&#xff0c;便于协同开发单页面路由易于结合其他的第三方库丰富的api方法轻量高效,虚拟DOMMVVM&#xff0c;数据驱动视图轻量级的框架 缺点&#xff1a; 缺少高阶教程和文档生态环境不如angular和re…

javascript 获取本机ip chrome 谷歌浏览器 extension 谷歌扩展

代码一&#xff1a; if (typeof window ! undefined) {var RTCPeerConnection window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;if (RTCPeerConnection)(() > {var rtc new RTCPeerConnection()rtc.createDataChannel(); //创…

Vscode初建Vue时几个需要注意的问题

首先放图 注意点1.打开文件夹时&#xff0c;可以是VUE2 或者其他&#xff0c;但不能是VUE&#xff0c;会报错 注意点2.终端输入命令“npm init -y" npm init -y -y 的含义&#xff1a;yes的意思&#xff0c;在init的时候省去了敲回车的步骤&#xff0c;生成的默认的packag…