0. 安装依赖
yum install -y libaio-devel libaio necurses-devel necurses readline-devel.x86_64 readline.x86_64 openssl openssl-devel
1. 安装 gcc
yum install -y centos-release-scl
yum install -y devtoolset-8-gcc.x86_64 devtoolset-8-gcc-c++.x86_64 devtoolset-8-gdb.x86_64 cmake
source /opt/rh/devtoolset-8/enable
gcc -v
2. 安装 cmake
wget https://github.com/Kitware/CMake/releases/download/v3.16.4/cmake-3.16.4-Linux-x86_64.sh
chmod +x cmake-3.16.4-Linux-x86_64.sh
./cmake-3.16.4-Linux-x86_64.sh --prefix=/usr/local
echo "export PATH=$PATH:/usr/local/cmake-3.16.4-Linux-x86_64/bin" >>/etc/profile & source /etc/profile
cmake --version
3. 下载源码包
wget https://mirrors.cloud.tencent.com/mysql/downloads/MySQL-8.0/mysql-boost-8.0.19.tar.gz
tar -xzvf MySQL-8.0/mysql-boost-8.0.19.tar.gz
4. 测试编译环境
cd /root/mysql-8.0.19
mkdir build
cd build
cmake ../ -DWITH_BOOST=../boost/
5. 编译MySQL
cd ..
rm -rf build
mkdir build
cmake ../
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql8
-DWITH_BOOST=../boost/
DEBUG 方式
cmake ../ \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql8 \
-DWITH_DEBUG=1 \
-DCMAKE_BUILD_TYPE=Debug \
-DWITH_BOOST=../boost/
6. 安装
make install
7. 建用户及实例目录
mkdir -p /data/mysql/mysql3306/{data,logs,tmp}
上传配置文件到/data/mysql/mysql3306/
groupadd mysql
useradd -g mysql -s /sbin/nologin -d /usr/local/mysql8 -MN mysql
chown -R mysql:mysql /usr/local/mysql8/
chown -R mysql:mysql /data/mysql/mysql3306/
8. 初始化database:
/usr/local/mysql8/bin/mysqld --defaults-file=/data/mysql/mysql3306/my3306.cnf --initialize
echo "export PATH=$PATH:/usr/local/mysql8/bin" >>/etc/profile & source /etc/profile
9. 启动MySQL Server:
/usr/local/mysql8/bin/mysqld_safe --defaults-file=/data/mysql/mysql3306/my3306.cnf &
10. 登录mysql
mysql -S /tmp/mysql3306.sock -p
11、改密码
cat /data/mysql/mysql3306/data/error.log | grep passwor
mysql -S /tmp/mysql3306.sock -p
mysql>alter user current_user() identified by 'abc123';
网友评论