Home Database Mysql Tutorial Detailed explanation of installing mysql5.7.18 instance on centos7.3

Detailed explanation of installing mysql5.7.18 instance on centos7.3

Jan 17, 2018 am 09:21 AM
Detailed explanation

This article mainly introduces the detailed tutorial for installing mysql5.7.18 on centos7.3. Friends who need it can refer to it. I hope it can help everyone.

1 Check the Linux release version

[root@typecodes ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

2 Download the official MySQL Yum Repository

According to the Linux distribution version (CentOS and Fedora are all Red Hat series), obtain Yum from the official mysql (http://dev.mysql.com/downloads/repo/yum/) Repository.

[root@typecodes ~]# wget -i http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
--2016-02-03 18:36:02-- http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm [following]
--2016-02-03 18:36:04-- http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 104.102.164.25
Connecting to repo.mysql.com (repo.mysql.com)|104.102.164.25|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8984 (8.8K) [application/x-redhat-package-manager]
Saving to: ‘mysql57-community-release-el7-7.noarch.rpm'
100%[=============================================================================================================================>] 8,984  --.-K/s in 0s
2016-02-03 18:36:07 (68.4 MB/s) - ‘mysql57-community-release-el7-7.noarch.rpm' saved [8984/8984]
3 安装MySQL的Yum Repository
安装完MySQL的Yum Repository,每次执行yum update都会检查MySQL是否更新。
[root@typecodes ~]# yum -y install mysql57-community-release-el7-7.noarch.rpm
Loaded plugins: axelget, fastestmirror, langpacks
Examining mysql57-community-release-el7-7.noarch.rpm: mysql57-community-release-el7-7.noarch
Marking mysql57-community-release-el7-7.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql57-community-release.noarch 0:el7-7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================================================================================
 Package          Arch      Version     Repository             Size
=======================================================================================================================================================================
Installing:
 mysql57-community-release      noarch      el7-7      /mysql57-community-release-el7-7.noarch      7.8 k
Transaction Summary
=======================================================================================================================================================================
Install 1 Package
Total size: 7.8 k
Installed size: 7.8 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Installing : mysql57-community-release-el7-7.noarch                            1/1 
 Verifying : mysql57-community-release-el7-7.noarch                           1/1
Installed:
 mysql57-community-release.noarch 0:el7-7
Complete!
Copy after login

3 Install the server version of the MySQL database

[root@typecodes ~]# yum -y install mysql-community-server
Loaded plugins: axelget, fastestmirror, langpacks
No metadata available for base
No metadata available for epel
No metadata available for extras
repomd.xml                                  | 2.5 kB 00:00:00  
update mysql-connectors-community metadata successfully
repomd.xml                                  | 2.5 kB 00:00:00  
update mysql-tools-community metadata successfully
repomd.xml                                  | 2.5 kB 00:00:00  
update mysql57-community metadata successfully
No metadata available for updates
mysql-connectors-community                              | 2.5 kB 00:00:00  
mysql-tools-community                               | 2.5 kB 00:00:00  
mysql57-community                                | 2.5 kB 00:00:00  
(1/3): mysql-tools-community/x86_64/primary_db                         | 24 kB 00:00:01  
(2/3): mysql57-community/x86_64/primary_db                          | 28 kB 00:00:01  
(3/3): mysql-connectors-community/x86_64/primary_db                        | 8.6 kB 00:00:02  
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.neusoft.edu.cn
 * extras: mirrors.163.com
 * updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.10-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.10-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) = 5.7.10-1.el7 for package: mysql-community-client-5.7.10-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.10-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.44-2.el7.centos will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.7.10-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:5.7.10-1.el7 will be obsoleting
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================================================================================
 Package           Arch       Version        Repository        Size
=======================================================================================================================================================================
Installing:
 mysql-community-libs        x86_64      5.7.10-1.el7       mysql57-community      2.2 M
  replacing mariadb-libs.x86_64 1:5.5.44-2.el7.centos
 mysql-community-libs-compat      x86_64      5.7.10-1.el7       mysql57-community      2.0 M
  replacing mariadb-libs.x86_64 1:5.5.44-2.el7.centos
 mysql-community-server        x86_64      5.7.10-1.el7       mysql57-community      142 M
Installing for dependencies:
 mysql-community-client        x86_64      5.7.10-1.el7       mysql57-community       24 M
 mysql-community-common        x86_64      5.7.10-1.el7       mysql57-community      269 k
Transaction Summary
=======================================================================================================================================================================
Install 3 Packages (+2 Dependent packages)
Total download size: 171 M
Downloading packages:
mysql-community-server-5.7.10-1.el7.x86_64.rpm                         | 142 MB 00:03:42  
mysql-community-libs-compat-5.7.10-1.el7.x86_64.rpm                        | 2.0 MB 00:00:03  
mysql-community-libs-5.7.10-1.el7.x86_64.rpm                         | 2.2 MB 00:00:05  
mysql-community-client-5.7.10-1.el7.x86_64.rpm                         | 24 MB 00:00:41  
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.10-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY00 ETA 
Public key for mysql-community-common-5.7.10-1.el7.x86_64.rpm is not installed
mysql-community-common-5.7.10-1.el7.x86_64.rpm                         | 269 kB 00:00:01  
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid  : "MySQL Release Engineering <mysql-build>"
 Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 Package : mysql57-community-release-el7-7.noarch (@/mysql57-community-release-el7-7.noarch)
 From  : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Installing : mysql-community-common-5.7.10-1.el7.x86_64                           1/6 
 Installing : mysql-community-libs-5.7.10-1.el7.x86_64                           2/6 
 Installing : mysql-community-client-5.7.10-1.el7.x86_64                           3/6 
 Installing : mysql-community-server-5.7.10-1.el7.x86_64                           4/6 
 Installing : mysql-community-libs-compat-5.7.10-1.el7.x86_64                          5/6 
 Erasing : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64                           6/6 
 Verifying : mysql-community-server-5.7.10-1.el7.x86_64                           1/6 
 Verifying : mysql-community-libs-compat-5.7.10-1.el7.x86_64                          2/6 
 Verifying : mysql-community-common-5.7.10-1.el7.x86_64                           3/6 
 Verifying : mysql-community-libs-5.7.10-1.el7.x86_64                           4/6 
 Verifying : mysql-community-client-5.7.10-1.el7.x86_64                           5/6 
 Verifying : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64                           6/6
Installed:
 mysql-community-libs.x86_64 0:5.7.10-1.el7   mysql-community-libs-compat.x86_64 0:5.7.10-1.el7   mysql-community-server.x86_64 0:5.7.10-1.el7
Dependency Installed:
 mysql-community-client.x86_64 0:5.7.10-1.el7          mysql-community-common.x86_64 0:5.7.10-1.el7
Replaced:
 mariadb-libs.x86_64 1:5.5.44-2.el7.centos
Complete!
[root@typecodes ~]# clear</mysql-build>
Copy after login

Last screenshot:

Detailed explanation of installing mysql5.7.18 instance on centos7.3

##4 Start the database:

[root@typecodes ~]# systemctl start mysqld.service
Copy after login
Then use the command systemctl status mysqld.service to view the service status after the MySQL database is started:

Detailed explanation of installing mysql5.7.18 instance on centos7.3

5 Get the initial password

Use YUM to install and After starting the MySQL service, the MySQL process will automatically print the root user's initial password in the process log:

#######从mysql进程日志中获取root用户的初始密码:ra%yk7urCBIh
[root@typecodes ~]# grep "password" /var/log/mysqld.log
2016-02-03T10:42:17.272166Z 1 [Note] A temporary password is generated for root@localhost: ra%yk7urCBIh
2016-02-03T10:42:36.776875Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:42:52.063138Z 3 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:42:57.564373Z 4 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:43:01.477007Z 5 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:46:03.642008Z 6 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:46:11.217889Z 7 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:47:44.755199Z 0 [Note] Shutting down plugin 'validate_password'
2016-02-03T10:47:46.505844Z 0 [Note] Shutting down plugin 'sha256_password'
2016-02-03T10:47:46.505851Z 0 [Note] Shutting down plugin 'mysql_native_password'
Copy after login
6 Modify the root user password

Use the root user's initial password obtained in Section 5, Then modify it:

set global validate_password_policy =0;//The default is 1, which is MEDIUM, so the password you set at the beginning must meet the length and must contain numbers, lowercase or uppercase letters, and special characters.


set global validate_password_length=4;//指定了密码中数据的长度
alter user root@localhost identified by 'crow';//修改密码
Copy after login
Increase remote access rights

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'crow' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Copy after login
Exit mysql, and then restart the service

systemctl restart mysqld
Copy after login
Open the 3306 port in the firewall

firewall-cmd --zone=public --add-port=3306/tcp --permanent
Copy after login
Restart the firewall

firewall-cmd --reload
[root@typecodes ~]# mysql -uroot -p
Enter password:    #######输入默认的root密码后回车
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.10
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
Copy after login
7 Installation completed

At this point, the installation of the MySQL5.7.10 database using the YUM method in CentOS7 is completed. As shown below, you can use the new root password to log in to MySQL.

[root@typecodes ~]# mysql -uroot -ppassword
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.10 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show databases;
+--------------------+
| Database   |
+--------------------+
| information_schema |
| mysql    |
| performance_schema |
| sys    |
+--------------------+
4 rows in set (0.00 sec)
mysql> clear
mysql> exit
Bye
[root@typecodes ~]# clear
Copy after login
Appendix 1: View the configuration information of the MySQL database

The MySQL configuration file is still /etc/my.cnf, and other installation information can be viewed through the mysql_config command. Among them, the dynamic library files are stored in the /usr/lib64/mysql directory.

Detailed explanation of installing mysql5.7.18 instance on centos7.3

Appendix 2: For C/C++ and other developers

Since you need to use header files such as mysql.h, you need to execute the following command to install mysql Just the development version.

[root@typecodes ~]# yum -y install mysql-community-devel
Copy after login
Appendix 3: Deleting MySQL's Repository

Because MySQL's Yum Repository was installed in Section 3, every time a yum operation is performed in the future, updates will be checked. If you want to remove this automatic checking operation, you can use the following command to uninstall the MySQL Repository.

[root@typecodes ~]# yum -y remove mysql57-community-release-el7-7.noarch
update 2017.04.10 11:10
Copy after login
Using the above yum method, you can also install the latest version mysql5.7.18 currently on the mysql official website. Just replace the version of the rmp package in Section 2, and the subsequent steps remain unchanged.

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
Copy after login
Related recommendations:


How to change the password for MySQL5.7.18

About the installation and configuration of mysql5.7.18 under centos6.4 Method graphic tutorial sharing

Tutorial on how to install the decompressed version of MySQL5.7.18 under Windows

The above is the detailed content of Detailed explanation of installing mysql5.7.18 instance on centos7.3. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed explanation of the mode function in C++ Detailed explanation of the mode function in C++ Nov 18, 2023 pm 03:08 PM

Detailed explanation of the mode function in C++ In statistics, the mode refers to the value that appears most frequently in a set of data. In C++ language, we can find the mode in any set of data by writing a mode function. The mode function can be implemented in many different ways, two of the commonly used methods will be introduced in detail below. The first method is to use a hash table to count the number of occurrences of each number. First, we need to define a hash table with each number as the key and the number of occurrences as the value. Then, for a given data set, we run

Detailed explanation of obtaining administrator rights in Win11 Detailed explanation of obtaining administrator rights in Win11 Mar 08, 2024 pm 03:06 PM

Windows operating system is one of the most popular operating systems in the world, and its new version Win11 has attracted much attention. In the Win11 system, obtaining administrator rights is an important operation. Administrator rights allow users to perform more operations and settings on the system. This article will introduce in detail how to obtain administrator permissions in Win11 system and how to effectively manage permissions. In the Win11 system, administrator rights are divided into two types: local administrator and domain administrator. A local administrator has full administrative rights to the local computer

Detailed explanation of division operation in Oracle SQL Detailed explanation of division operation in Oracle SQL Mar 10, 2024 am 09:51 AM

Detailed explanation of division operation in OracleSQL In OracleSQL, division operation is a common and important mathematical operation, used to calculate the result of dividing two numbers. Division is often used in database queries, so understanding the division operation and its usage in OracleSQL is one of the essential skills for database developers. This article will discuss the relevant knowledge of division operations in OracleSQL in detail and provide specific code examples for readers' reference. 1. Division operation in OracleSQL

Detailed explanation of remainder function in C++ Detailed explanation of remainder function in C++ Nov 18, 2023 pm 02:41 PM

Detailed explanation of the remainder function in C++ In C++, the remainder operator (%) is used to calculate the remainder of the division of two numbers. It is a binary operator whose operands can be any integer type (including char, short, int, long, etc.) or a floating-point number type (such as float, double). The remainder operator returns a result with the same sign as the dividend. For example, for the remainder operation of integers, we can use the following code to implement: inta=10;intb=3;

Detailed explanation of the usage of Vue.nextTick function and its application in asynchronous updates Detailed explanation of the usage of Vue.nextTick function and its application in asynchronous updates Jul 26, 2023 am 08:57 AM

Detailed explanation of the usage of Vue.nextTick function and its application in asynchronous updates. In Vue development, we often encounter situations where data needs to be updated asynchronously. For example, data needs to be updated immediately after modifying the DOM or related operations need to be performed immediately after the data is updated. The .nextTick function provided by Vue emerged to solve this type of problem. This article will introduce the usage of the Vue.nextTick function in detail, and combine it with code examples to illustrate its application in asynchronous updates. 1. Vue.nex

Detailed explanation of php-fpm tuning method Detailed explanation of php-fpm tuning method Jul 08, 2023 pm 04:31 PM

PHP-FPM is a commonly used PHP process manager used to provide better PHP performance and stability. However, in a high-load environment, the default configuration of PHP-FPM may not meet the needs, so we need to tune it. This article will introduce the tuning method of PHP-FPM in detail and give some code examples. 1. Increase the number of processes. By default, PHP-FPM only starts a small number of processes to handle requests. In a high-load environment, we can improve the concurrency of PHP-FPM by increasing the number of processes

Detailed explanation of the linux system call system() function Detailed explanation of the linux system call system() function Feb 22, 2024 pm 08:21 PM

Detailed explanation of Linux system call system() function System call is a very important part of the Linux operating system. It provides a way to interact with the system kernel. Among them, the system() function is one of the commonly used system call functions. This article will introduce the use of the system() function in detail and provide corresponding code examples. Basic Concepts of System Calls System calls are a way for user programs to interact with the operating system kernel. User programs request the operating system by calling system call functions

Detailed explanation of the role and usage of PHP modulo operator Detailed explanation of the role and usage of PHP modulo operator Mar 19, 2024 pm 04:33 PM

The modulo operator (%) in PHP is used to obtain the remainder of the division of two numbers. In this article, we will discuss the role and usage of the modulo operator in detail, and provide specific code examples to help readers better understand. 1. The role of the modulo operator In mathematics, when we divide an integer by another integer, we get a quotient and a remainder. For example, when we divide 10 by 3, the quotient is 3 and the remainder is 1. The modulo operator is used to obtain this remainder. 2. Usage of the modulo operator In PHP, use the % symbol to represent the modulus

See all articles