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

How to install MySQL5.7 database and configure it under CentOS7

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article focuses on "how to install MySQL5.7 database and configuration under CentOS7". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to install MySQL5.7 database and configure it under CentOS7.

1. The main features of MySQL5.7:

Native architecture supports Systemd for centos7

(1.) better performance: better optimization and better innoDB storage engine for multicore CPU, solid state drives, locks.

(2.) more robust replication: replication brings a solution that does not lose data at all, and traditional financial customers also

You can choose to use the MySQL database.

(3.) add sys library: this will be the most frequently accessed library by DBA in the future.

(4.) better optimizer: the significance of optimizer code refactoring will bring huge improvements in version 5.7 and later

Oracle officials are solving the biggest problem before MySQL, native JSON type support.

Note: JSON (JavaScript object Notation) is a lightweight data exchange format.

JSON uses a completely language-independent text format, but also uses habits similar to the C language family

(including C, C++, C #, Java, JavaScript, Perl, Python, etc.).

These features make JSON an ideal data exchange language. Easy to read and write, and easy to parse by machine

And generation (generally used to increase the network transmission rate).

JSON syntax is a subset of JavaScript object representation syntax

The data is in the key value pair

Data is separated by commas

Curly braces save objects

Square brackets save array

Files written in JSON can replace files in .yaml format. (if needed in dockerkubernetes, create a RC).

Note: mysql-5.6.3 already supports multithreaded master-slave replication.

Second, source code compilation and installation of MySQL5.7

1. System environment: centos7.2x64 bit

Because mariadb-libs is installed by default in centos7.2, you need to uninstall it first.

two。 Install related dependency packages

Cmake: since the regular configure compilation method has been deprecated from the MySQL5.5 version, a CMAKE compiler is required, using the

In setting the compilation parameters of mysql. Such as: installation directory, data storage directory, character encoding, sorting rules and so on.

Boot: starting with Mysql5.7.5, the Boost library is required. C++ 's Boost library is used in the MySQL source code, and security is required.

Install boost1.59.0 or above.

GCC is a C language compilation tool under Linux. MySQL source code compilation is written entirely in C and C++. GCC is required to be installed.

C _ syntax + parser under bison:Linux

Ncurses: character terminal processing library

Download the required software:

Download cmake-3.5.tar.gz http://www.cmake.org/download

Download ncurses-5.9.tar.gz ftp://ftp.gnu.org/gnu/ncurses/

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

Download mysql-5.7.13.tar.gz

Wget http://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.18.tar.gz

Download Boost_1_59_0.tar.gz

Wget http://nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz

3. Install cmake and related downloaded software

1. Install cmake:

Cmake-version View version:

two。 Install ncurses:

3. Install bison:

4. Install boost:

Because boost is a pre-compiled software, there is no need to configure and compile here, so you can use it directly by moving to the specified directory.

4. Create MySQL users and user groups and directories

Create a new MySQL combination MySQL user, disable login to shell,-r option: on behalf of the system user

5. Compile and install MySQL5.7.18

(1.) decompress the mysql source package:

(2.) compile and configure before executing the cmake command:

Note: in mysql5.5-5.6 version, it is not necessary to add the-DWITH_SYSTEMD=1 parameter, otherwise an error will be reported!

(3.) start compilation and installation:

Configuration explanation:

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql: root directory of mysql installation

-DMYSQL_DATADIR=/usr/local/mysql/data: directory where mysql database files are stored

-DSYSCONFDIR=/etc: the directory where the 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 the mysql.sock location

-DWITH_PARTITION_STORAGE_ENGINE=1: install to support database partitions

-DEXTRA_CHARSETS=all: enable mysql to support all extended characters

-DDEFAULT_CHARSET=utf8: sets the default character set of mysql to utf-8

-DDEFAULT_COLLATION=utf8_general_ci: sets default character set alignment rules

-DWITH_SYSTEMD=1: you can use systemd to control mysql services

-DWITH_BOOST=/usr/local/boost: point to the directory where the boost library is located

Note: more parameters are executed: # cmake. -LH

To speed up the compilation, you can compile and install as follows:

Make-j $(grep processor / proc/cpuinfo | wc-l)

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.

Note: to rerun the cmake configuration, you need to delete the CMakeCache.txt file

# make clean

# rm-f CMakeCache.txt

6. Optimize the execution path of MySQL

7. Set permissions and initialize the MySQL system authorization table

Note: the above root initialization operation needs to add the-- initialize parameter to generate a random password (note to save the password to be used when logging in)

Previous versions of MySQL5.7.6 executed this script to initialize the system database:

/ usr/local/mysql/bin/mysql_install_db-user=mysql-basedir=/usr/local/mysql

-- datadir=/usr/local/mysql/data

Initialization with password:

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

Password-free initialization:

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

8. Create a profile

Vim / etc/my.cnf

The above server failed to start. View the error log file

In mysqld.service, the default pid file is assigned to the / var/run/mysqld directory without creating the directory in advance, so create the directory manually and assign permissions to the MySQL user. This method is temporary because the directory shutdown under / var/run/ is gone.

Or modify / usr/lib/system/system/mysqld.service:

# systemctl daemon-reload

At this point, I believe you have a deeper understanding of "how to install MySQL5.7 database and configuration under CentOS7". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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