一键安装mysql5.7

	要使用这个文档,需要搭建好yum本地源
	需要安装的工具 :yum -y install vim ntp unzip wget net-tools lrzsz
	各个工具的作用:ntp:时间同步工具,unzip解压zip包用的,wget:下载用的,net-tools:常见的网络工具		包,如netstat命令,lrzsz:上传下载包用的,主要用在xshell中
	搭建好环境之后,需要通过rz命令将mysql-community-5.7.26-1.el7.src.rpm上传到虚拟机的/root目录,然后复制粘贴即可,之后只需要自动完成,此时你听听歌,打游戏完全是可以的

rpm -ivh mysql-community-5.7.26-1.el7.src.rpm &&
cd rpmbuild/ &&
cd SOURCES/ &&
cp boost_1_59_0.tar.bz2 mysql-5.7.26.tar.gz /root &&
cd &&
yum -y remove boost-* &&
yum install -y bzip2
tar -jxvf boost_1_59_0.tar.bz2 &&
yum -y remove mysql* &&
yum -y remove mariadb* &&
yum install -y cmake make gcc gcc-c++ bison ncurses ncurses-devel &&
groupadd mysql &&
useradd -M -s /sbin/nologin -r -g mysql mysql &&
mkdir -p /data/mysql/{data,log}&&
chown -R mysql:mysql /data/mysql/ &&
tar -zxvf mysql-5.7.26.tar.gz &&
cd 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 &&
make -j $( grep processor /proc/cpuinfo | wc -l) &&
make install &&
cd &&
chown -R mysql:mysql /usr/local/mysql/ &&
mv /etc/my.cnf{,.bak} &&
cd &&
echo '[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=/usr/local/mysql/log/mysqld.log
pid-file=/usr/local/mysql/mysqld.pid ’ > /etc/my.cnf &&
cd &&
rm -rf /etc/init.d/mysqld
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld &&
chmod +x /etc/init.d/mysqld &&
chkconfig --add mysqld &&
chkconfig mysqld on && r
chkconfig --list mysqld &&
cd /usr/local/mysql/data &&
rm -rf * &&
cd &&
/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/ &&
mysqladmin -u root password “123456”

你可能感兴趣的:(mysql)