Bloggers recently look at the database , Share it mysql Relevant experience , It is strongly recommended to learn from the official website documents !!!
One 、 Environmental preparation and related references
machine | Centos7.8 |
The Internet | Connected to the Internet |
mysql Official website | https://www.mysql.com/cn/ |
Official website installation guide 5.7 | https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html |
RPM package :
Two 、 Check for installation mysql and mariadb, Unload related , Prevent subsequent installation errors
rpm -qa | grep mariadb rpm -qa | grep mysql yum remove -y mariadb-libs-5.5.65-1.el7.x86_64
3、 ... and 、 Get the latest official source , In this way, you can download the latest official rpm package
# Download files to home Under the soft Folder
cd /home/soft wget https://repo.mysql.com//mysql80-community-release-el7-5.noarch.rpm
# Local installation
yum localinstall mysql80-community-release-el7-5.noarch.rpm # Update the source and check whether the installation is successful yum clean all && yum makecache # Query exists mysql The relevant package yum repolist enabled | grep "mysql.*-community.*" yum repolist all | grep mysql
Four 、 Enable mysql5.7 Source , This installation mysql5.7 edition
yum -y install yum-utils # Enable mysql5.7, Ban mysql8.0 yum-config-manager --disable mysql80-community yum-config-manager --enable mysql57-community yum repolist all | grep mysql
5、 ... and 、 install mysql5.7 edition
yum install mysql-community-server -y
# Although there is only one command , But when installing, I will help you install the corresponding tools
# This will install MySQL Software package for server ( mysql-community-server) And the software package of the components required to run the server ,
Including the software package of the client ( mysql-community-client)、
Common error messages and character sets for clients and servers ( mysql-community-common)
And shared client libraries ( mysql-community-libs)
Relevant installation records
[[email protected] soft]# yum install mysql-community-server -y Loaded plug-in :fastestmirror Loading mirror speeds from cached hostfile * elrepo: hkg.mirror.rackspace.com Resolving dependencies --> Checking transactions ---> software package mysql-community-server.x86_64.0.5.7.37-1.el7 Will be install --> Dealing with dependencies mysql-community-common(x86-64) = 5.7.37-1.el7, It's packaged mysql-community-server-5.7.37-1.el7.x86_64 need --> Dealing with dependencies mysql-community-client(x86-64) >= 5.7.9, It's packaged mysql-community-server-5.7.37-1.el7.x86_64 need --> Checking transactions ---> software package mysql-community-client.x86_64.0.5.7.37-1.el7 Will be install --> Dealing with dependencies mysql-community-libs(x86-64) >= 5.7.9, It's packaged mysql-community-client-5.7.37-1.el7.x86_64 need ---> software package mysql-community-common.x86_64.0.5.7.37-1.el7 Will be install --> Checking transactions ---> software package mysql-community-libs.x86_64.0.5.7.37-1.el7 Will be install --> Resolve dependency complete Dependency resolution ========================================================================================================================= Package framework edition Source size ========================================================================================================================= Installing : mysql-community-server x86_64 5.7.37-1.el7 mysql57-community 174 M Install for dependency : mysql-community-client x86_64 5.7.37-1.el7 mysql57-community 25 M mysql-community-common x86_64 5.7.37-1.el7 mysql57-community 311 k mysql-community-libs x86_64 5.7.37-1.el7 mysql57-community 2.4 M Business summary ========================================================================================================================= install 1 software package (+3 Dependent packages ) Total Downloads :202 M Installation size :878 M Downloading packages: Warning :/var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.37-1.el7.x86_64.rpm: head V4 RSA/SHA256 Signature, secret key ID 3a79bd29: NOKEY mysql-community-common-5.7.37-1.el7.x86_64.rpm The public key for has not been installed (1/4): mysql-community-common-5.7.37-1.el7.x86_64.rpm | 311 kB 00:00:02 (2/4): mysql-community-libs-5.7.37-1.el7.x86_64.rpm | 2.4 MB 00:00:01 (3/4): mysql-community-client-5.7.37-1.el7.x86_64.rpm | 25 MB 00:00:07 (4/4): mysql-community-server-5.7.37-1.el7.x86_64.rpm | 174 MB 00:00:32 ------------------------------------------------------------------------------------------------------------------------- A total of 5.6 MB/s | 202 MB 00:00:36 from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022 Search key Import GPG key 0x3A79BD29: user ID : "MySQL Release Engineering <[email protected]>" The fingerprint : 859b e8d7 c586 f538 430b 19c2 467b 942d 3a79 bd29 software package : mysql80-community-release-el7-5.noarch (@/mysql80-community-release-el7-5.noarch) come from : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022 from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql Search key Import GPG key 0x5072E1F5: user ID : "MySQL Release Engineering <[email protected]>" The fingerprint : a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5 software package : mysql80-community-release-el7-5.noarch (@/mysql80-community-release-el7-5.noarch) come 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.37-1.el7.x86_64 1/4 Installing : mysql-community-libs-5.7.37-1.el7.x86_64 2/4 Installing : mysql-community-client-5.7.37-1.el7.x86_64 3/4 Installing : mysql-community-server-5.7.37-1.el7.x86_64 4/4 Verification in progress : mysql-community-server-5.7.37-1.el7.x86_64 1/4 Verification in progress : mysql-community-libs-5.7.37-1.el7.x86_64 2/4 Verification in progress : mysql-community-common-5.7.37-1.el7.x86_64 3/4 Verification in progress : mysql-community-client-5.7.37-1.el7.x86_64 4/4 already installed : mysql-community-server.x86_64 0:5.7.37-1.el7
6、 ... and 、 After installation , start-up mysql, View version , Set up root password
# Start and set the power on self start systemctl start mysqld systemctl enable mysqld systemctl status mysqld # View version mysql --version mysql Ver 14.14 Distrib 5.7.37, for Linux (x86_64) using EditLine wrapper # Look at the initial root password , And reset grep 'temporary password' /var/log/mysqld.log 2022-02-14T03:31:21.363571Z 1 [Note] A temporary password is generated for [email protected]: H1(yRxS!js_u Initial password :H1(yRxS!js_u # Sign in mysql, And reset root password mysql -u root -p Enter the initial password Format :mysql> set password for user name @localhost = password(' New password '); Or use :ALTER USER 'root'@'localhost' IDENTIFIED BY 'root-password'; Example :mysql> set password for [email protected] = password('[email protected]'); # Pay attention to the complexity of password setting , Be safe . If you want to change your simple password , use Baidu Search
7、 ... and 、 Set allow remote login , Use software to remotely access mysql
# View the current database mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) # Set to allow remote mysql> use mysql; mysql> select user,host from user; mysql> update user set host="%" where user="root";
# Refresh the permissions mysql> flush privileges;
8、 ... and 、 The basic installation is completed , Additional explanation
l install 8.0 Version reference above , take 8.0 Start the source of version
l After installation , It is recommended to turn off the firewall or turn on 3306 port , Otherwise, you can't be far away (systemctl stop firewalld)
l This article refers to the installation steps in the official document , Use yum Installation , Non binary installation , It is strongly recommended to read the official documents