本文共 2541 字,大约阅读时间需要 8 分钟。
yum install ncurses-devel -y yum install glibc-devel.i686 glibc-devel -y yum install gcc gcc-c++ -y 另外,MySQL8.0需要用gcc的版本为 4.8以上,而centos 6.4通过yum只能安装到4.4.7,所以在安装mysql8.0之前需要手动安装更高版本的gcc,我这里以gcc-8.8.2为例:
# 载编译需要的依赖包:
./contrib/download_prerequisites ./configure --prefix= /usr/local/gcc-4.8.2/ --enable-bootstrap --enable-threads=posix --enable-languages=c,c++,objc,obj-c++ 安装完后,还需要将原来的gcc环境用新版本的gcc替换掉,否则mysql在安装时还是用的原来的gcc:
mv /usr/bin/gcc /usr/bin/gcc447 mv /usr/bin/g++ /usr/bin/g++447 mv /usr/bin/c++ /usr/bin/c++447 mv /usr/bin/cc /usr/bin/cc447 ln -s /usr/local/gcc-4.8.2/bin/ gcc /usr/bin/gcc ln -s /usr/local/gcc-4.8.2/bin/ g++ /usr/bin/g++ ln -s /usr/local/gcc-4.8.2/bin/ c++ /usr/bin/c++ ln -s /usr/local/gcc-4.8.2/bin/ gcc /usr/bin/cc mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.bak ln -s /usr/local/gcc-4.8.2/lib64/libstdc++.so.6.0.18 /usr/lib64/libstdc++.so.6 ./b2 stage threading=multi link=shared ./b2 install threading=multi link=shared wget -c http://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-8.0.0-dmr.tar.gz tar xf mysql-boost-8.0.0-dmr.tar.gz cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/usr/local/mysql/data/ -DSYSCONFDIR=\etc\mysql \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_BOOST=/tmp/boost_1_60_0/ # 新增mysql用户和组,并配置mysql用户对数据库目录的权限 chown mysql.mysql /usr/local/mysql -R bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/ cp ./support-files/my-default.cnf /etc/my.cnf datadir=/usr/local/mysql/data/ socket=/var/lib/mysql/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks pid-file=/var/run/mysqld/mysqld.pid log-error=/var/log/mysqld.log chown mysql /var/run/mysqld/ -R echo "export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/sbin" >> /etc/profile cp support-files/mysql.server /etc/init.d/mysql.server chkconfig mysql.server on service mysql.server start 转载地址:http://fnikl.baihongyu.com/