一、Mysql 下载地址
二、安装gcc11
gcc
[root@centos7-0 workspace_mysql]# yum install centos-release-scl-rh [root@centos7-0 workspace_mysql]# yum install devtoolset-11-gcc* [root@centos7-0 workspace_mysql]# source /opt/rh/devtoolset-11/enable [root@centos7-0 workspace_mysql]# gcc --version gcc (GCC) 11.2.1 20220127 (Red Hat 11.2.1-9) Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
三、安装make
yum install -y ncurses-devel [root@centos7-0 make-4.4]# tar -zxvf make-4.4.tar.gz [root@centos7-0 make-4.4]# cd make-4.4 [root@centos7-0 make-4.4]# ./configure --disable-dependency-tracking [root@centos7-0 make-4.4]# ./build.sh [root@centos7-0 make-4.4]# ./make [root@centos7-0 make-4.4]# ./make install [root@centos7-0 home]# make --version GNU Make 4.4 Built for x86_64-pc-linux-gnu Copyright (C) 1988-2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
四、安装 cmake
[root@centos7-0 workspace_mysql]# tar -zxvf cmake-3.25.1.tar.gz [root@centos7-0 workspace_mysql]# cd cmake-3.25.1 [root@centos7-0 workspace_mysql]# ./configure [root@centos7-0 workspace_mysql]# yum install -y openssl openssl-devel [root@centos7-0 workspace_mysql]# make [root@centos7-0 workspace_mysql]# make install [root@centos7-0 workspace_mysql]# cmake --version cmake version 3.25.1 CMake suite maintained and supported by Kitware (kitware.com/cmake).
五、开始编译
yum install -y wget
# Preconfiguration setup $> groupadd mysql $> useradd -r -g mysql -s /bin/false mysql # Beginning of source-build specific instructions $> tar -zxvf mysql-boost-8.0.30.tar.gz $> cd mysql-8.0.30/ $> vim extra/libedit/libedit-20210910-3.1/src/terminal.c 将852行的 `area = buf` 改成 `area = NULL` (不改的话,登录时会报错:Segmentation fault (core dumped))(如果没有terminal.c这个文件的话,可以执行```locate terminal.c```) $> mkdir bld $> cd bld 下面cmake这一步,会报错,根据报错提示,加上提示里头的参数,重新执行即可。 $> mkdir boost && cmake .. -DDOWNLOAD_BOOST=1 -DWITH_BOOST=boost $> make $> make install
后续启动步骤如下:
[root@centos7-0 bld]# cd /usr/local/mysql [root@centos7-0 mysql]# ls LICENSE LICENSE.router README-test bin include man mysqlrouter-log-rotate share var LICENSE-test README README.router docs lib mysql-test run support-files [root@centos7-0 mysql]# ll total 716 -rw-r--r-- 1 root root 287624 Jul 6 21:36 LICENSE -rw-r--r-- 1 root root 287624 Jul 6 21:36 LICENSE-test -rw-r--r-- 1 root root 121393 Jul 6 21:36 LICENSE.router -rw-r--r-- 1 root root 666 Jul 6 21:36 README -rw-r--r-- 1 root root 666 Jul 6 21:36 README-test -rw-r--r-- 1 root root 679 Jul 6 21:36 README.router drwxr-xr-x 2 root root 4096 Dec 13 04:32 bin drwxr-xr-x 2 root root 86 Dec 13 04:32 docs drwxr-xr-x 3 root root 282 Dec 13 04:32 include drwxr-xr-x 6 root root 247 Dec 13 04:32 lib drwxr-xr-x 4 root root 42 Dec 13 04:32 man drwxr-xr-x 10 root root 4096 Dec 13 04:32 mysql-test -rw-r--r-- 1 root root 1623 Dec 13 00:01 mysqlrouter-log-rotate drwxrwxr-x 2 root root 6 Dec 13 04:32 run drwxr-xr-x 28 root root 4096 Dec 13 04:32 share drwxr-xr-x 2 root root 77 Dec 13 04:32 support-files drwxr-xr-x 3 root root 17 Dec 13 04:32 var [root@centos7-0 mysql]# mkdir mysql-files [root@centos7-0 mysql]# chown mysql:mysql mysql-files [root@centos7-0 mysql]# chmod 750 mysql-files [root@centos7-0 mysql]# bin/mysqld --initialize --user=mysql 2022-12-13T04:33:42.909660Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.30) initializing of server in progress as process 68776 2022-12-13T04:33:42.916979Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2022-12-13T04:33:43.616784Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2022-12-13T04:33:44.772683Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: haIuuL?lt0ge [root@centos7-0 mysql]# bin/mysql_ssl_rsa_setup [root@centos7-0 mysql]# bin/mysqld_safe --user=mysql & [1] 68828 [root@centos7-0 mysql]# Logging to '/usr/local/mysql/data/centos7-0.err'. 2022-12-13T04:33:59.627920Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data [root@centos7-0 mysql]# cp support-files/mysql.server /etc/init.d/mysql.server [root@centos7-0 mysql]# date Tue Dec 13 04:34:15 UTC 2022
六、验证安装
可以看到命令行交互模式下,数据库是能正常使用的了
- 可以看到navicat也能远程正常连接了
修复
1、通过命令 locate terminal.c查找到我们的这个文件 [root@localhost mysql-8.0.18]# locate terminal.c /opt/mysql-8.0.18/extra/libedit/terminal.c /opt/mysql-8.0.18/extra/libedit/CMakeFiles/edit.dir/terminal.c.o 2、修改文件/opt/mysql-8.0.18/extra/libedit/terminal.c,将 area = buf;改为 area = NULL; 3、重新再编译的目录下重新 make 和 make install