1. 下载MySQL 8.0.22 源码包: wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.22.tar.gz
https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.22.tar.gz
2. 解压源码包:
tar -zxvf mysql-8.0.22.tar.gz -C /usr/local
3. 创建用于编译的构建目录:
mkdir mysql-8.0.22-build
cd mysql-8.0.22-build
4. 运行CMake生成编译选项:
cmake也要3**版本以上的 提前升级
我安装是 cmake-3.21.2,不然也会提示报错cmake版本太低
cmake ../mysql-8.0.22 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
5. 依赖错误
- Found Git: /usr/bin/git (found version "1.8.3.1")
-- This is el6, el7 or el8 as found from 'uname -r' or 'rpm -qf /'
-- We probably need some devtoolset compiler
CMake Warning at CMakeLists.txt:294 (MESSAGE):
Could not find devtoolset gcc
-- MySQL 8.0.22
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Source directory /usr/local/mysql-8.0.22
-- Binary directory /usr/local/mysql-8.0.22-build
-- CMAKE_GENERATOR: Unix Makefiles
CMake Error at cmake/os/Linux.cmake:84 (MESSAGE):
GCC 5.3 or newer is required (-dumpversion says 4.8.5)
Call Stack (most recent call first):
CMakeLists.txt:508 (INCLUDE)
-- Configuring incomplete, errors occurred!
See also "/usr/local/mysql-8.0.22-build/CMakeFiles/CMakeOutput.log".
处理方式就是升级gcc版本 二进制安装太麻烦
提供一个yun安装的方式
yum -y install gcc tcl
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
echo "source /opt/rh/devtoolset-9/enable" >> /etc/profile
退出会话窗口重更新连接
gcc -v 查看版本
6. 在camke还会提示依赖问题
wget https://boost.org/Foobar1.73.0/boost_1_73_0.tar.gz
--2023-05-25 10:56:58-- https://boost.org/Foobar1.73.0/boost_1_73_0.tar.gz
Resolving boost.org (boost.org)... 146.20.110.251
Connecting to boost.org (boost.org)|146.20.110.251|:443... connected.
ERROR: cannot verify boost.org's certificate, issued by ‘/C=US/O=Let's Encrypt/CN=R3’:
Issued certificate has expired.
To connect to boost.org insecurely, use `--no-check-certificate'.
需要 安装boost_1_73_0.tar.gz
wget https://boostorg.jfrog.io/artifactory/main/release/1.73.0/source/boost_1_73_0.tar.gz
安装boot 编译mysql
tar -xvf boost_1_73_0.tar.gz -C /usr/local
cd /usr/local/boost_1_73_0
./bootstrap.sh && ./b2 && sudo ./b2 install
重新进行cmake
cd /usr/local/mysql-8.0.22-build
cmake ../mysql-8.0.22 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DMYSQL_TCP_PORT=3306 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_BOOST=/usr/local/
注意 最后一行加上了 -DWITH_BOOST=/usr/local/
make && sudo make install
7. 如果有这个报错
CMake Error at /usr/local/mysql-8.0.22/cmake/do_abi_check.cmake:80 (MESSAGE):
sed returned error No such file or directory
make[2]: *** [CMakeFiles/abi_check] Error 1
make[1]: *** [CMakeFiles/abi_check.dir/all] Error 2
我的建议是 删除重新执行
我这边是可以的
cmake ../mysql-8.0.22 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DMYSQL_TCP_PORT=3306 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_BOOST=/usr/local/boost_1_73_0 -DWITH_ABI_CHECK=OFF
make && make install
8.配置my.cnf文件 初始化数据
1、
vim /usr/local/mysql/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
basedir=/usr/local/mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
socket=/tmp/mysql.sock
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
# include all files from the config directory
#
!includedir /etc/my.cnf.d
2、初始化
[root@localhost bin]# chmod -R 755 /usr/local/mysql/
[root@localhost bin]# chown -R mysql.mysql /usr/local/mysql
[root@localhost bin]# mysqld --initialize --user=mysql
2023-05-25T07:15:25.790589Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2023-05-25T07:15:25.790667Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.22) initializing of server in progress as process 388880
2023-05-25T07:15:25.794850Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-05-25T07:15:26.152239Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-05-25T07:15:26.686473Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: wxxPQI>Is0VL #记住这个密码
3、启动服务
mysqld_safe --user=mysql &
[1] 391739
[root@localhost bin]# 2023-05-25T07:21:27.388468Z mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
2023-05-25T07:21:27.406231Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
#停止mysqld_safe stop
#启动 mysqld_safe &
4、ll /tmp/mysql.sock
srwxrwxrwx. 1 mysql mysql 0 May 25 15:21 /tmp/mysql.sock
9. 登录数据库
mysql -uroot -p 输入初始化的 密码
10. 修改密码
mysql> alter user 'root'@'localhost' identified by '123';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
真的这源码安装实在是麻烦了,各种依赖真的吐了 cmake的命令丢。你们安装的时候自己配置吧