时间:2021-07-01 10:21:17 帮助过:12人阅读
说明:MySQL8.0需要用gcc的版本为 4.8以上,而centos 6.5通过yum只能安装到4.4.7,所以在安装mysql8.0之前需要手动安装更高版本的gcc,我这里以gcc-8.8.2为例:
1 wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.gz 2 tar xf gcc-4.8.2.tar.gz 3 cd gcc-4.8.2
# 载编译需要的依赖包:
1 ./contrib/download_prerequisites 2 ./configure --prefix=/usr/local/gcc-4.8.2/ --enable-bootstrap --enable-threads=posix --enable-languages=c,c++,objc,obj-c++ 3 make &&make install
说明:make的时间会很长,安装完后,还需要将原来的gcc环境用新版本的gcc替换掉,否则mysql在安装时还是用的原来的gcc。
1 mv /usr/bin/gcc /usr/bin/gcc447 2 mv /usr/bin/g++ /usr/bin/g++447 3 mv /usr/bin/c++ /usr/bin/c++447 4 mv /usr/bin/cc /usr/bin/cc447 5 ln -s /usr/local/gcc-4.8.2/bin/gcc /usr/bin/gcc 6 ln -s /usr/local/gcc-4.8.2/bin/g++ /usr/bin/g++ 7 ln -s /usr/local/gcc-4.8.2/bin/c++ /usr/bin/c++ 8 ln -s /usr/local/gcc-4.8.2/bin/gcc /usr/bin/cc 9 mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.bak 10 ln -s /usr/local/gcc-4.8.2/lib64/libstdc++.so.6.0.18 /usr/lib64/libstdc++.so.6
解决如下问题:
接着,安装boost库:
1 wget -c http://sourceforge.net/projects/boost/files/boost/1.60.0/boost_1_60_0.tar.bz2 --no-check-certificate 2 tar xf boost_1_60_0.tar.bz2\?r\=\&ts\=1479114685\&use_mirror\=ncu 3 cd boost_1_60_0 4 ./bootstrap.sh 5 ./b2 stage threading=multi link=shared 6 ./b2 install threading=multi link=shared
mysql5.1的时候用传统的.configure,make,make install 就就可以了,但是从5.5后编译安装就需要cmake,make, make install来安装,所以要安装cmake。
1 cd /home/king/tools 2 wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz 3 tar zxf cmake-2.8.4.tar.gz 4 cd cmake-2.8.4 5 ./configure 6 make & make install
当然了,在安装软件的时候都应该先用rpm -qa | grep cmake 来查看是否已经安装,如果没有在执行以上命令。wget-c 断点续传下载文件。-O 指定目录下载(或者理解为下载到指定的目录)
1 # 下载和解压mysql 2 wget -c http://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-8.0.0-dmr.tar.gz 3 tar xf mysql-boost-8.0.0-dmr.tar.gz 4 5 # 编译安装mysql 6 cd mysql-8.0.0-dmr 7 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql 8 -DMYSQL_DATADIR=/usr/local/mysql/data/ -DSYSCONFDIR=\etc\mysql 9 -DWITH_INNOBASE_STORAGE_ENGINE=1 10 -DMYSQL_TCP_PORT=3306 11 -DENABLED_LOCAL_INFILE=1 12 -DEXTRA_CHARSETS=all 13 -DDEFAULT_CHARSET=utf8 14 -DDEFAULT_COLLATION=utf8_general_ci 15 -DWITH_BOOST=/tmp/boost_1_60_0/ 16 make 17 make install 18 19 # 新增mysql用户和组,并配置mysql用户对数据库目录的权限 20 groupadd mysql 21 useradd -g mysql mysql #也可以useradd mysql -s /sbin/nologin -M -g mysql 22 chown mysql.mysql /usr/local/mysql -R 23 # 初始化mysql 24 cd /usr/local/mysql 25 bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/ 26 bin/mysql_ssl_rsa_setup 27 28 # 配置文件 29 cp ./support-files/my-default.cnf /etc/my.cnf 30 vim /etc/my.cnf #编辑/etc/my.conf文件 31 [mysqld] 32 datadir=/usr/local/mysql/data/ 33 socket=/var/lib/mysql/mysql.sock 34 user=mysql #mysql用户 35 # Disabling symbolic-links is recommended to prevent assorted security risks 36 symbolic-links=0 37 pid-file=/var/run/mysqld/mysqld.pid 38 log-error=/var/log/mysqld.log 39 40 # 创建进程文件目录 41 mkdir /var/run/mysqld 42 chown mysql /var/run/mysqld/ -R 43 44 # 设置环境变量 45 echo "export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/sbin" >> /etc/profile 46 source /etc/profile #./etc/profile 47 48 # 设置开机启动脚本 49 cd /usr/local/mysql 50 cp support-files/mysql.server /etc/init.d/mysql.server 51 chkconfig mysql.server on 52 service mysql.server start
到此MySQl就编译安装完成,但是工作中并不常用mysql8.0,只是出于好奇,看了一看,下面是小编二进制安装MySQl亲测哦。
1 useradd mysql -s /sbin/nologin -M 2 mkdir /application/mysql/data -p 3 chown mysql.mysql /application/mysq/data/
1 wget http://mysql.ntu.edu.tw/Downloads/MySQL-5.5/mysql-5.5.32-linux2.6-x86_64.tar.gz 2 tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz 3 mv mysql-5.5.32-linux2.6-x86_64 /application/mysql-5.5.32 4 ln -s /application/mysql-5.5.32 /application/mysql
1 echo ‘PATH=$PATH:/usr/local/mysql/bin‘ >>/etc/profile 2 source /etc/profile 或者./etc/profile
1 cd /application/mysql 2 ./scripts/mysql_install_db --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data/ 3 cp support-files/my-small.cnf /etc/my.cnf 4 cp support-files/my.server /etc/init.d/mysqld 5 chmod +x /etc/init.d/mysqld 6 /etc/init.d/mysqld start
MySQl编译安装与二进制安装介绍
标签:inux ln -s 支持 download rip nload install mkdir general