Compile and install MySQL8.0

The official version 8.0.11 of MySQL 8.0 has been released. Officially, MySQL 8 is 2 times faster than MySQL 5.7, and it also brings a lot of improvements and faster performance!

Note: Upgrading from MySQL 5.7 to MySQL 8.0 is only supported using in-place upgrades, and downgrading from MySQL 8.0 to MySQL 5.7 is not supported

(or downgrade from a MySQL 8.0 version to any earlier MySQL 8.0 version). The only supported alternative is to back up your data before upgrading.


Operating system description: CentOS 6.4

Database version: MySQL 8.0.0

1. Environmental preparation

yum install ncurses-devel -y

yum install libaio -y

yum install glibc-devel.i686 glibc-devel -y

yum install gcc gcc-c++ -y

In addition, MySQL8.0 needs to use gcc version 4.8 or above, and centos 6.4 can only be installed to 4.4.7 through yum, so you need to manually install a higher version of gcc before installing mysql8.0, I use gcc-8.8 here. 2 for example:

wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.gz

tar xf gcc-4.8.2.tar.gz

cd  gcc-4.8.2

# Download the dependencies required for compilation: ./contrib/download_prerequisites

./configure --prefix=/usr/local/gcc-4.8.2/   --enable-bootstrap --enable-threads=posix --enable-languages=c,c++,objc,obj-c++

make &&make install

Note: make will take a long time.

After installation, you also need to replace the original gcc environment with the new version of gcc, otherwise mysql will still use the original gcc during installation:

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

Solve the following problems:

Next, install the boost library:

wget -c http://sourceforge.net/projects/boost/files/boost/1.60.0/boost_1_60_0.tar.bz2  --no-check-certificate

tar xf boost_1_60_0.tar.bz2\?r\=\&ts\=1479114685\&use_mirror\=ncu

cd boost_1_60_0

./bootstrap.sh

./b2 stage threading=multi link=shared

./b2 install threading=multi link=shared

2. Install mysql8.0

# Download and unzip mysql

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

# Compile and install mysql

cd mysql-8.0.0-dmr

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql  \

-DMYSQL_DATADIR=/usr/local/mysql/data/ -DSYSCONFDIR=\etc\mysql \

-DWITH_INNOBASE_STORAGE_ENGINE=1   \

-DMYSQL_TCP_PORT=3306   \

-DENABLED_LOCAL_INFILE=1   \

-DEXTRA_CHARSETS=all   \

-DDEFAULT_CHARSET=utf8   \

-DDEFAULT_COLLATION=utf8_general_ci  \

-DWITH_BOOST=/tmp/boost_1_60_0/

make

make install

# Add mysql user and group, and configure the mysql user's permissions to the database directory

groupadd mysql  

useradd -g mysql mysql  

chown mysql.mysql /usr/local/mysql -R

# Initialize mysql

cd   /usr/local/mysql

bin/mysqld --initialize --user=mysql  --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/

bin/mysql_ssl_rsa_setup

# config file

cp ./support-files/my-default.cnf /etc/my.cnf  

vim /etc/my.cnf

[mysqld]

datadir=/usr/local/mysql/data/

socket=/var/lib/mysql/mysql.sock

user=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

pid-file=/var/run/mysqld/mysqld.pid

log-error=/var/log/mysqld.log

# Create process file directory

mkdir /var/run/mysqld

chown mysql /var/run/mysqld/ -R

# set environment variables

echo "export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/sbin" >> /etc/profile

source  /etc/profile

# Set up the startup script

cd   /usr/local/mysql

cp support-files/mysql.server /etc/init.d/mysql.server

chkconfig mysql.server on

service mysql.server start


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324595106&siteId=291194637