中科院镜像站安装:http://mirrors.ustc.edu.cn
使用 rpm -ivh 依次下载安装common, libs, client, devel, server
mysql-community-common-5.7.26-1.el7.x86_64.rpm
mysql-community-libs-5.7.26-1.el7.x86_64.rpm
mysql-community-client-5.7.26-1.el7.x86_64.rpm
mysql-community-devel-5.7.26-1.el7.x86_64.rpm
mysql-community-server-5.7.26-1.el7.x86_64.rpm
#官网安装:
#下载mysql源:https://dev.mysql.com/downloads/repo/yum/
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
#安装mysql:https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
#安装源
sudo rpm -Uvh mysql80-community-release-el7-3.noarch.rpm
#查看包信息:
yum repolist all | grep mysql
yum repolist enabled | grep mysql
#设置可用包:
sudo yum-config-manager --disable mysql80-community
sudo yum-config-manager --enable mysql57-community
#安装
sudo yum install mysql-community-server
#启动
sudo systemctl start mysqld.service
#查看root用户密码
grep 'temporary password' /var/log/mysqld.log
#修改密码:
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
编译安装
#安装依赖包
yum -y install gcc gcc-c++ ncurses ncurses-devel cmake
#下载相应源码包
#boost
wget http://downloads.sourceforge.NET/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
或
wget https://nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
#mysql
wget http://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.9.tar.gz
或
wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.9.tar.gz
#添加mysql用户
useradd -M -s /sbin/nologin mysql
groupadd mysql
useradd -r -g mysql mysql
tar xzf boost_1_59_0.tar.gz
tar xzf mysql-5.7.9.tar.gz
mkdir -p /data/mysql
cd mysql-5.7.9
#编译安装
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/root/boost_1_59_0 \
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DENABLE_DTRACE=0 \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DWITH_EMBEDDED_SERVER=1
make -j `grep processor /proc/cpuinfo | wc -l`
make install
# 启动脚本,设置开机自启动
/bin/cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
来源:oschina
链接:https://my.oschina.net/icmll/blog/4320357