Centos7.2 install mysql5.7

 

1. The main features of MySQL 5.7:

Primitive support Systemd 

Better performance: better optimized and better InnoDB storage engine for multi-core CPUs, SSDs, locks

More robust replication function: Replication brings a solution that does not lose data at all, and traditional financial customers can also choose to use MySQL databases.

Note: mysql-5.6.3 already supports multi-threaded master-slave replication

New sys library: this will be the most frequently accessed library by DBAs in the future

Second, install mysql5.7.13

1. System environment: centos7.2 x86_64

# uname -r
3.10.0-327.el7.x86_64
# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)  

Because centos7.2 installs mariadb-libs by default, it must be uninstalled first

Check if mariadb is installed

#rpm -qa | grep mariadb

uninstall mariadb

rpm -e --nodeps mariadb-libs

# rpm -qa |grep mariadb
mariadb-libs-5.5.44-2.el7.centos.x86_64
# rpm -e --nodeps mariadb-libs
# rpm -qa |grep mariadb

2. Install dependency packages

Note: The role of related dependency packages

cmake: Since the regular configure compilation method has been deprecated since MySQL 5.5, the CMake compiler is required to set the compilation parameters of mysql. Such as: installation directory, data storage directory, character encoding, sorting rules, etc. Boost #Starting from MySQL 5.7.5, the Boost library is required. The C++ Boost library is used in the mysql source code. It is required to install boost1.59.0 or above.

GCC is a C language compilation tool under Linux. The mysql source code compilation is completely written in C and C++, and must be installed

GCC

bison: C/C++ parser for Linux

ncurses: character terminal processing library

Software link:

Install cmake, pay attention to ./bootstrap is an error, saying that the package of gcc is missing

So you need to install gcc first

# yum -y install gcc gcc-c++
# tar -xvf cmake-3.5.2.tar.gz
# cd cmake-3.5.2/
# ./bootstrap
# gmake && gmake install   

cmake --version --- View cmake version

# cmake -version
cmake version 3.5.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).

install ncurses

# tar -xvf ncurses-5.9.tar.gz
# cd ncurses-5.9/
# ./configure && make && make install

install bison

# tar -xvf bison-3.0.4.tar.gz
# cd bison-3.0.4/
# ./configure && make && make install

install bootst

# tar -xvf boost_1_59_0.tar.gz
# mv boost_1_59_0 /usr/local/boost

3) Create mysql user and user group and directory

# groupadd -r mysql && useradd -r -g mysql -s /bin/false -M mysql --- New msyql group and msyql user are prohibited from logging into the shell
# mkdir /data/soft/mysql --- create directory
# mkdir /data/soft/mysql/data --- database directory

3. Compile and install mysql

Unzip the mysql source package:

# tar -xvf mysql-5.7.18.tar.gz
# cd mysql-5.7.18 /
# cmake -DCMAKE_INSTALL_PREFIX=/data/soft/mysql -DMYSQL_DATADIR=/data/soft/mysql/data -DSYSCONFDIR=/etc  -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1  -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/data/soft/mysql/mysql.sock -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_c -DWITH-SYSTEMD=1 -DWITH_BOOST=/usr/local/boost
# make && make install  

Note 1: Configuration explanation:

-DCMAKE_INSTALL_PREFIX=/data/soft/mysql [root directory of MySQL installation]
-DMYSQL_DATADIR=/data/soft/mysql/data [MySQL database file storage directory]
-DSYSCONFDIR=/etc [directory where MySQL configuration file is located]
-DWITH_MYISAM_STORAGE_ENGINE=1 [Add MYISAM engine support]
-DWITH_INNOBASE_STORAGE_ENGINE=1 [Add InnoDB engine support]
-DWITH_ARCHIVE_STORAGE_ENGINE=1 [Add ARCHIVE engine support]
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock [specify mysql.sock location]
-DWITH_PARTITION_STORAGE_ENGINE=1 [install support database partition]
-DEXTRA_CHARSETS=all [make MySQL support all extended characters]
-DDEFAULT_CHARSET=utf8 [Set MySQL's default character set to utf8]
-DDEFAULT_COLLATION=utf8_general_ci [set default character set collation]
-DWITH-SYSTEMD=1 [can use systemd to control mysql service]
-DWITH_BOOST=/usr/local/boost [point to the directory where the boost library is located]

  

2 : In order to speed up the compilation, you can compile and install in the following way

make -j $(grep processor /proc/cpuinfo | wc –l) && make install 

The -j parameter indicates that the number of threads at compile time is specified according to the number of CPU cores, which can speed up the compilation. Defaults to 1 thread compilation. If you don't use this during testing, it will consume more resources. It is estimated that the system will display make errors after two attempts. I have done it a few times, and they are all prompted like this, so the test can be done honestly. This can be used in a production environment because the server configuration is better.

Note 3: To re-run the cmake configuration, you need to delete the CMakeCache.txt file

# make clean
#rm -f  CMakeCache.txt

Optimize the execution path of Mysql

# vim /etc/profile
Edit variable path content
export PATH=$PATH:/data/soft/mysql/bin
# source /etc/profile

4. Set permissions and initialize the MySQL system authorization table

# cd /data/soft/mysql/
# chown -R mysql:mysql .

  

  Pending. . .

 

 

Guess you like

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