一键部署----shell脚本安装MySQL5.7
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一键部署----shell脚本安装MySQL5.7相关的知识,希望对你有一定的参考价值。
一键部署----shell脚本安装mysql5.7
#/bin/bash
yum -y install ncurses bison cmake gcc gcc-c++ ncurses-devel
useradd mysql -s /sbin/nologin
read -p "输入你存放压缩包的绝对路径:" abc
cd $abc
tar zxvf boost_1_59_0.tar.gz
tar zxvf mysql-5.7.17.tar.gz
mv boost_1_59_0 /usr/local/boost
cd mysql-5.7.17/
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=/usr/local/boost -DWITH_SYSTEMD=1
make
make install
chown -R mysql:mysql /usr/local/mysql/
cd /etc
rm -rf my.cnf
touch my.cnf
echo "[client]" >>my.cnf
echo "port = 3306" >>my.cnf
echo "default-character-set=utf8" >>my.cnf
echo "socket = /usr/local/mysql/mysql.sock" >>my.cnf
echo " " >>my.cnf
echo "[mysql]" >>my.cnf
echo "port = 3306" >>my.cnf
echo "default-character-set=utf8" >>my.cnf
echo "socket=/usr/local/mysql/mysql.sock" >>my.cnf
echo " " >>my.cnf
echo "[mysqld]" >>my.cnf
echo "user = mysql" >>my.cnf
echo "basedir = /usr/local/mysql" >>my.cnf
echo "datadir=/usr/local/mysql/data" >>my.cnf
echo "port = 3306" >>my.cnf
echo "character_set_server=utf8" >>my.cnf
echo "pid-file = /usr/local/mysql/mysqld.pid" >>my.cnf
echo "socket = /usr/local/mysql/mysql.sock" >>my.cnf
echo "server-id = 1" >>my.cnf
echo " ">>my.cnf
echo "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" >>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 /lib/systemd/system/
systemctl daemon-reload
systemctl start mysqld
netstat -ntap |grep 3306
以上是关于一键部署----shell脚本安装MySQL5.7的主要内容,如果未能解决你的问题,请参考以下文章