编译安装MySQL8及常见错误处理
初稿。。。
1.下载
https://downloads.mysql.com/archives/community/
选择对应版本->选择 source code ->系统版本一定要选all ->拉至最下方-选择mysql-boost-8.0.xx.tar.gz(不下载带有boost的压缩包,需自行安装boost)
图片后续添加。
2.解压
tar -zxf mysql-boost-8.0.25.tar.gz
3.编译安装
#预编译 cmake3 -DCMAKE_INSTALL_PREFIX=/home/apps/mysql -DMYSQL_UNIX_ADDR=/home/apps/mysql.sock -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DCMAKE_C_COMPILER=/home/apps/gcc/bin/gcc -DCMAKE_CXX_COMPILER=/home/apps/gcc/bin/g++ -DFORCE_INSOURCE_BUILD=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/home/downloads/mysql/mysql-8.0.25/boost -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 #编译 make #安装 make install
4.初始化
#配置文件/etc/my.cnf
[mysqld]
datadir=/home/data
socket=/home/apps/mysql/mysql.sock
bind-address=0.0.0.0(可根据情况修改为本机IP)
port=3306
#创建用户
useradd -s /sbin/nologin -M mysql
#初始化
cd /home/apps/mysql/bin/ ./mysqld --initialize --user=mysql --basedir=/home/apps/mysql --datadir=/home/data
#启动登录并更新密码
./mysqld_safe --user=mysql
mysql -u root -p -h 127.0.0.1 -P 3306
use mysql;
select user,host from mysql;
alter user 'root'@'localhost' identified by '123456';
#添加远程登录
create user 'root'@'%' identified by '123456';
grant all privileges on *.* to 'root'@'%' with grant option;
flush privileges;
二、常见错误
1.Please install the appropriate openssl developer package
Cannot find appropriate system libraries for WITH_SSL=system. Make sure you have specified a supported SSL version. Valid options are : system (use the OS openssl library), yes (synonym for system), </path/to/custom/openssl/installation> CMake Error at cmake/ssl.cmake:61 (MESSAGE): Please install the appropriate openssl developer package. Call Stack (most recent call first): cmake/ssl.cmake:315 (FATAL_SSL_NOT_FOUND_ERROR) CMakeLists.txt:1344 (MYSQL_CHECK_SSL) -- Configuring incomplete, errors occurred! See also "/home/downloads/mysql/mysql-8.0.25/CMakeFiles/CMakeOutput.log". See also "/home/downloads/mysql/mysql-8.0.25/CMakeFiles/CMakeError.log".
解决方案
yum install openssl-devel
2.gcc版本过低
升级gcc gcc下载地址 http://www.netgull.com/gcc/releases/gcc-9.3.0 依赖包下载地址 ftp://gcc.gnu.org/pub/gcc/infrastructure/ gmp-6.1.0.tar.bz2 isl-0.18.tar.bz2 mpfr-3.1.4.tar.bz2 mpc-1.0.3.tar.gz ./configure make && make install tar -zxf gcc-9.3.0.tar.gz && cd gcc-9.3.0 ./configure --prefix=/home/apps/gcc --enable-bootstrap --enable-checking=release --enable-languages=c,c++ --disable-multilib make make install #添加环境变量 vim /etc/profile #添加下述内容 GCC_HOME=/home/apps/gcc export PATH=$GCC_HOME/bin:$PATH source /etc/profile
3./lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found
../runtime_output_directory/uca9dump: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by ../runtime_output_directory/uca9dump) make[2]: *** [strings/uca900_zh_tbls.cc] Error 1 make[1]: *** [strings/CMakeFiles/strings_objlib.dir/all] Error 2 make: *** [all] Error 2
解决方案
gcc升级时,新版本动态库未覆盖旧版本动态库 删除旧软连接。生成新链接 find / -name libstdc++.so.6 rm /usr/lib/libstdc++.so.6 /usr/lib64/libstdc++.so.6 ln -s /home/apps/gcc/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6 ln -s /home/apps/gcc/lib64/libstdc++.so.6 /usr/lib/libstdc++.so.6
4.error: ‘SYS_gettid’ was not declared in this scope
In function ‘void buf_pool_create(buf_pool_t*, ulint, ulint, std::mutex*, dberr_t&)’: /home/downloads/mysql/mysql-8.0.25/storage/innobase/buf/buf0buf.cc:1228:44: error: ‘SYS_gettid’ was not declared in this scope
解决方案
在文件buf0buf.cc的开头添加: #include "sys/syscall.h" 再次make
5.error while loading shared libraries: libisl.so.15: cannot open shared object file: No such file or directory
/etc/ld.so.conf 添加如下内容 include ld.so.conf.d/*.conf /usr/local/lib find /usr/local/lib -name libisl.so.15 /usr/local/lib 为libisl.so.15所在目录 文件内容添加后,执行ldconfig #查看当前动态库 ldconfig -p
解压文件脚本
#!/bin/bash COM_DIR=$1 DECOM_DIR=$2 get_file(){ ls $COM_DIR>>/tmp/filelist.txt FILELIST=/tmp/filelist.txt n=1 j=`(wc -l $FILELIST|awk '{print $1}')` cat $FILELIST |awk -F'.' '{print $NF}'|while read i do if [ $i = gz ];then if [ $n -le $j ];then sed -n "$n"p $FILELIST >>/tmp/gz_file.txt n=$(($n + 1)) fi elif [ $i = bz2 ];then if [ $n -le $j ];then sed -n "$n"p $FILELIST >>/tmp/bz2_file.txt n=$(($n + 1)) fi else if [ $n -le $j ];then sed -n "$n"p $FILELIST >>/tmp/other_file.txt n=$(($n + 1)) fi fi done } decom_gz(){ cat /tmp/gz_file.txt|while read i do tar -zxf $COM_DIR/$i -C $DECOM_DIR &>/dev/null if [ $? -eq 0 ];then echo "$i decom successed." else echo "$i decom failed." fi done } decom_bz2(){ cat /tmp/bz2_file.txt|while read i do tar -jxf $COM_DIR/$i -C $DECOM_DIR &>/dev/null if [ $? -eq 0 ];then echo "$i decom successed." else echo "$i decom failed." fi done } del_tmp_file(){ rm /tmp/filelist.txt /tmp/other_file.txt /tmp/bz2_file.txt /tmp/gz_file.txt -f } if [ -z $1 -o -z $2 ];then echo "Please enter the compressed file directory and decompression directory" echo "eg: ./decom.sh /tmp/gcc /home/apps/gcc " else get_file decom_bz2 decom_gz del_tmp_file fi