Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Compile and install MySQL 5.7on CentOS 7

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. System environment

[root@szlinux02 ~] # uname-r

3.10.0-514.el7.x86_64

[root@szlinux02 ~] # cat / etc/redhat-release

CentOS Linux release 7.3.1611 (Core)

[root@szlinux02 ~] # rpm-qa | grep mariadb

Mariadb-libs-5.5.52-1.el7.x86_64

[root@szlinux02] # rpm-e-- nodeps mariadb-libs [root@szlinux02 ~] # [root@szlinux02 ~] # yum install-y gcc gcc-c++ perl

two。 Install dependency packages

The role of related dependency packages

Cmake: since the regular configure compilation method has been deprecated from the MySQL5.5 version, a CMake compiler is required to set the compilation parameters for mysql. Such as: installation directory, data storage directory, character encoding, sorting rules and so on.

Boost:# Boost library is required from MySQL 5.7.5. C++ 's Boost library is used in mysql source code, which requires boost1.59.0 or above to be installed.

GCC: C language compilation tool under Linux. Mysql source code compilation is written entirely by C and C++. GCC is required to be installed.

C _ syntax + parser under bison:Linux

Ncurses: character terminal processing library

1) preparation of installation files

Download the cmake-3.8.1.tar.gz source release package

Http://www.cmake.org/download/

Wget https://cmake.org/files/v3.8/cmake-3.8.1.tar.gz

Download ncurses-6.0.tar.gz

Ftp://ftp.gnu.org/gnu/ncurses/

Wget ftp://ftp.gnu.org/gnu/ncurses/ncurses-6.0.tar.gz

Download M4-1.4.18.tar.gz

Wget http://mirrors.kernel.org/gnu/m4/m4-1.4.18.tar.gz

Download bison-3.0.4.tar.gz

Http://ftp.gnu.org/gnu/bison/

Wget http://ftp.gnu.org/gnu/bison/bison-3.0.4.tar.gz

Download mysql-5.7.18.tar.gz

Wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18.tar.gz

Download Boost_1_59_0.tar.gz

Wget https://ncu.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz

2) install CMAKE and necessary software

Install cmake

[root@szlinux02 ~] # tar zxvf cmake-3.8.1.tar.gz [root@szlinux02 ~] # cd cmake-3.8.1 [root@szlinux02 cmake-3.8.1] #. / bootstrap [root@szlinux02 cmake-3.8.1] # gmake & & gmake install [root@szlinux02 cmake-3.8.1] # cmake- version [root@szlinux02 cmake-3.8.1] # cd ~

Install M4

[root@szlinux02 ~] # tar zxvf M4-1.4.18.tar.gz [root@szlinux02 ~] # cd M4-1.4.18 [root@szlinux02 M4-1.4.18] #. / configure [root@szlinux02 M4-1.4.18] # make & & make install [root@szlinux02 M4-1.4.18] # cd ~

Install bison (Note: perl and M4 support are required)

[root@szlinux02 ~] # tar zxvf bison-3.0.4.tar.gz [root@szlinux02 ~] # cd bison-3.0.4 [root@szlinux02 bison-3.0.4] #. / configure [root@szlinux02 bison-3.0.4] # make & & make install [root@szlinux02 bison-3.0.4] # cd ~

Install ncurses

[root@szlinux02 ~] # tar zxvf ncurses-6.0.tar.gz [root@szlinux02 ~] # cd ncurses-6.0 [root@szlinux02 ncurses-6.0] #. / configure [root@szlinux02 ncurses-6.0] # make & & make install [root@szlinux02 ncurses-6.0] # cd ~

Install boost (Note: the correct version of boost required for MySQL 5.7.18 is boost_1_59_0)

[root@szlinux02 ~] # tar zxvf boost_1_59_0.tar.gz [root@szlinux02 ~] # mv boost_1_59_0 / usr/local/boost

3. Create mysql users, user groups, and directories

[root@szlinux02] # groupadd-r mysql & & useradd-r-g mysql-s / bin/false-M mysql [root@szlinux02] # mkdir / usr/local/mysql [root@szlinux02] # mkdir-p / data/mysql

4. Pre-compilation

[root@szlinux02] # tar zxvf mysql-5.7.18.tar.gz [root@szlinux02] # cd mysql-5.7.18 [root@szlinux02 mysql-5.7.18] # cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql\-DMYSQL_DATADIR=/data/mysql\-DWITH_BOOST=/usr/local/boost\-DSYSCONFDIR=/etc\-DWITH_INNOBASE_STORAGE_ENGINE=1\-DWITH_PARTITION_STORAGE_ENGINE=1\-DWITH_FEDERATED_STORAGE_ENGINE=1\-DWITH_BLACKHOLE_STORAGE_ENGINE=1\-DWITH_MYISAM_STORAGE_ENGINE=1\-DENABLED_LOCAL_INFILE=1\-DENABLE_DTRACE=0\-DDEFAULT_ CHARSET=utf8mb4\-DDEFAULT_COLLATION=utf8mb4_general_ci\-DWITH_EMBEDDED_SERVER=OFF

5. Compilation and installation

[root@szlinux02 mysql-5.7.18] # make-j `grep processor / proc/cpuinfo | wc-l` [root@szlinux02 mysql-5.7.18] # make install

The-j parameter specifies the number of threads at compile time based on the number of CPU cores, which can speed up compilation. The default is 1 thread compilation.

6. Set permissions and initialize the MySQL system authorization table

[root@szlinux02 mysql-5.7.18] # cd / usr/local/mysql [root@szlinux02 mysql] # chown-R mysql:mysql. [root@szlinux02 mysql] # mkdir temp [root@szlinux02 mysql] # chmod 777. / temp [root@szlinux02 mysql] # cd / data/mysql [root@szlinux02 mysql] # chown-R mysql:mysql.

Versions of MySQL prior to 5.7.6 execute this script to initialize the system database

. / bin/mysql_install_db-- user=mysql-- basedir=/usr/local/mysql-- datadir=/data/mysql

Version of the initial system database script after 5.7.6

[root@szlinux02 mysql] # cd / usr/local/mysql [root@szlinux02 mysql] #. / bin/mysqld-initialize-insecure-user=mysql-basedir=/usr/local/mysql-datadir=/data/mysql

Note:

The previous version of MySQL, mysql_install_db, is under mysql_basedir/script, and MySQL 5.7 is placed directly under the mysql_basedir/bin directory.

"--initialize" has been discarded, generating a random password (~ / .mysql_secret)

"--initialize-insecure" does not generate a password

There can be no data files in the "--datadir" directory

[root@szlinux02 mysql] #. / bin/mysql_ssl_rsa_setup

7. Create a profile

[root@szlinux02 mysql] # cat > / etc/my.cnf > / etc/profile & & source / etc/profile

11. Set the database root user password

[root@szlinux02 mysql] #. / bin/mysql_secure_installation

twelve。 Create additional MySQL database users

[root@szlinux02 mysql] # mysql-uroot-p mysql > CREATE DATABASE `testdb` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; mysql > grant all privileges on testdb.* to 'ryanxu'@'%' identified by' ABCabc123 benchmark; mysql > flush privileges; myqsl > exit

Error summary:

1. If the compilation fails, you need to delete the cache file of the precompiled configuration parameters generated by cmake and the file generated after make compilation, and then recompile.

[root@szlinux02 mysql-5.7.18] # make clean [root@szlinux02 mysql-5.7.18] # rm-f CMakeCache.txt

two。 If you report an error,

Make [2]: * * [libmysqld/examples/mysql_client_test_embedded] error 1

Make [1]: * * [libmysqld/examples/CMakeFiles/mysql_client_test_embedded.dir/all] error 2

Plus

-DWITH_EMBEDDED_SERVER=OFF

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report