CentOS7安装过程中报libstdc++.so.6缺失
在二进制安装Mysql8.0.33过程中,出现了如下报错信息:
./mysqld: /lib64/libstdc++.so.6: version `CXXABI_1.3.11' not found (required by ./mysqld) ./mysqld: /lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by ./mysqld) ./mysqld: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by ./mysqld) ./mysqld: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by ./mysqld) ./mysqld: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./mysqld) ./mysqld: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by ./mysqld) ./mysqld: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by ./mysqld) ./mysqld: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by /usr/local/mysql/bin/../lib/private/libcrypto.so.1.1) ./mysqld: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /usr/local/mysql/bin/../lib/private/libprotobuf-lite.so.3.19.4) ./mysqld: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /usr/local/mysql/bin/../lib/private/libprotobuf-lite.so.3.19.4) ./mysqld: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /usr/local/mysql/bin/../lib/private/libprotobuf-lite.so.3.19.4) ./mysqld: /lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /usr/local/mysql/bin/../lib/private/libprotobuf-lite.so.3.19.4) ./mysqld: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /usr/local/mysql/bin/../lib/private/libprotobuf-lite.so.3.19.4)
查看发现服务器中libstdc++.so.6指向的是同目录的libstdc++.so.6.0.19,并且本地只有libstdc++.so.6.0.19,而其中没有需要的库。根据网上找到的办法,重新下载了libstdc++.so.6.0.25,并且将libstdc++.so.6软连接指向libstdc++.so.6.0.25。之后报错变为了
./mysqld: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
查下来发现是版本冲突,但是libstdc++-4.8.5-44.el7已经是CentOS的最新版本了。
之后又找了一下发现需要升级gcc,由于我是内网服务器无法验证yum安装,所以这里提供一个连接,大家自己尝试一下:https://zhuanlan.zhihu.com/p/535657060。我这里采用编译安装gcc
同样,libc.so.6发现指向的是同目录的libc-2.17.so,其中一样没有需要的库,需要升级glibc。也采用编译安装glibc
gcc官网:https://gcc.gnu.org/;下载地址:https://ftp.gnu.org/gnu/
(1).GMP编译安装(gcc的依赖包)
我这里下载gmp-6.2.1.tar.xz
[root@youxi1 ~]# yum -y install m4 [root@youxi1 ~]# tar xvf gmp-6.2.1.tar.xz [root@youxi1 ~]# cd gmp-6.2.1 [root@youxi1 gmp-6.2.1]# mkdir tmp [root@youxi1 gmp-6.2.1]# cd tmp/ [root@youxi1 tmp]# ../configure --prefix=/usr/local/gmp-6.2.1 [root@youxi1 tmp]# echo $? 0 //返回0表示成功 [root@youxi1 tmp]# make -j 4 && make install [root@youxi1 tmp]# echo $? 0 //返回0表示成功
(2).MPFR编译安装(gcc的依赖包)
我这里下载mpfr-4.2.0.tar.gz
[root@youxi1 tmp]# cd ~ [root@youxi1 ~]# tar zxvf mpfr-4.2.0.tar.gz [root@youxi1 ~]# cd mpfr-4.2.0 [root@youxi1 mpfr-4.2.0]# mkdir tmp [root@youxi1 mpfr-4.2.0]# cd tmp [root@youxi1 tmp]# ../configure --prefix=/usr/local/mpfr-4.2.0 --with-gmp=/usr/local/gmp-6.2.1 [root@youxi1 tmp]# echo $? 0 //返回0表示正常 [root@youxi1 tmp]# make -j 4 && make install [root@youxi1 tmp]# echo $? 0 //返回0表示正常
(3).MPC编译安装(gcc的依赖包)
我这里下载mpc-1.3.1.tar.gz
[root@youxi1 tmp]# cd ~ [root@youxi1 ~]# tar zxvf mpc-1.3.1.tar.gz [root@youxi1 ~]# cd mpc-1.3.1 [root@youxi1 mpc-1.3.1]# mkdir tmp [root@youxi1 mpc-1.3.1]# cd tmp [root@youxi1 tmp]# ../configure --prefix=/usr/local/mpc-1.3.1 --with-gmp=/usr/local/gmp-6.2.1 --with-mpfr=/usr/local/mpfr-4.2.0 [root@youxi1 tmp]# echo $? 0 //返回0表示正常 [root@youxi1 tmp]# make -j 4 && make install [root@youxi1 tmp]# echo $? 0 //返回0表示正常
(4).添加环境变量
需要将依赖包添加到环境变量中否则会报错。注意:这里添加LD_LIBRARY_PATH时,echo $LD_LIBRARY_PATH输出是不是空,如果不是空,将值复制补全,不要用LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-1.3.1/lib:/usr/local/gmp-6.2.1/lib:/usr/local/mpfr-4.2.0/lib,在下面安装glibc时我会讲原因。
[root@youxi1 tmp]# vi /etc/profile //最后一行添加 export LD_LIBRARY_PATH=/usr/local/mpc-1.3.1/lib:/usr/local/gmp-6.2.1/lib:/usr/local/mpfr-4.2.0/lib [root@youxi1 tmp]# source /etc/profile //重新加载
如果不添加环境变量,编译安装gcc时,会报如下错误:
error while loading shared libraries: libmpfr.so.6: cannot open shared object file: No such file or directory
(5).gcc编译安装
我这里下载gcc-13.1.0.tar.gz
[root@youxi1 tmp]# cd ~ [root@youxi1 ~]# tar zxvf gcc-13.1.0.tar.gz [root@youxi1 ~]# cd gcc-13.1.0 [root@youxi1 gcc-13.1.0]# mkdir tmp && cd tmp [root@youxi1 tmp]# ../configure --prefix=/usr/local/gcc-13.1.0 --enable-language=c,c++,java --disable-multilib --with-gmp=/usr/local/gmp-6.2.1 --with-mpfr=/usr/local/mpfr-4.2.0 --with-mpc=/usr/local/mpc-1.3.1 [root@youxi1 tmp]# echo $? 0 //返回0表示正常 [root@youxi1 tmp]# make -j 4 && make install [root@youxi1 tmp]# echo $? 0 //返回0表示正常 [root@youxi1 tmp]# vi /etc/profile //最后一行添加 export PATH=/usr/local/gcc-13.1.0/bin/:$PATH [root@youxi1 tmp]# . /etc/profile //重新加载
(6).替换libstdc.so.6,并进行测试
替换软链接
[root@youxi1 tmp]# cd /usr/lib64/ [root@youxi1 lib64]# rm -rf libstdc++.so.6 [root@youxi1 lib64]# ln -s /usr/local/gcc-13.1.0/lib64/libstdc++.so.6 ./libstdc++.so.6
启动二进制mysqld看下报错有没有变少,我启动后报错变成了如下情况:
./mysqld: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by ./mysqld) ./mysqld: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by /usr/local/mysql/bin/../lib/private/libcrypto.so.1.1) ./mysqld: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /usr/local/mysql/bin/../lib/private/libprotobuf-lite.so.3.19.4)
一下子问题就去掉大半了,下面就是升级glibc。
(7).剩下的问题处理不了了,我升级了glibc,但牵扯到其他问题无法使用。只能到这里了
参考:https://blog.csdn.net/qq_35107621/article/details/130718534
https://www.cnblogs.com/moher/p/3236713.html
https://www.jianshu.com/p/f0a079671f39