How to install and configure Mysql5.7 on Centos7

小云云
Release: 2019-12-30 17:31:07
Original
18352 people have browsed it

There are countless tutorials on installing mysql database on Linux on the Internet, but most of them are full of loopholes. Today, in order to help those who need it, I wrote a tutorial on installing and configuring mysql5.7 on Centos7.

Recommended related mysql video tutorials: "mysql tutorial"

The first step: Get the mysql YUM source

Enter the mysql official website to obtain the RPM package download address

https://dev.mysql.com/downloads/repo/yum/

Right-click to copy the link address https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

Get the address of the rpm package

Recommended Manual: MySQL Development Manual

Step 2: Download and install mysql source

Download mysql first Source installation package

[root@localhost ~]# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

-bash: wget: command not found

Let’s install wget first

yum -y install wget

then executewget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

Install mysql source

yum - y localinstall mysql57-community-release-el7-11.noarch.rpm

Step 3: Install Mysql online

yum -y install mysql-community-server

It will take a while to download a lot of things;

Step 4: Start the Mysql service

systemctl start mysqld

Step 5: Set up startup

systemctl enable mysqld systemctl daemon-reload
Copy after login
Recommended related articles:
1. Installing mysql under CentOS7 Detailed steps for -server
2. How to install mysql and php in Centos7
Related video recommendations:
1. MySQL authoritative development Guide

Step 6: Modify the root local login password

After the mysql installation is completed, in the /var/log/mysqld.log file A temporary default password is generated for root.

vi /var/log/mysqld.log

##The password here is: xtqh0Neteu=7

mysql -u root -p Enter password:
Copy after login

Enter the temporary password to enter the mysql command line;

ALTER USER 'root'@'localhost' IDENTIFIED BY 'LCode1996.';

Change the password to LCode1996. (Note that the default password policy of mysql5.7 requires that the password must be a combination of uppercase and lowercase alphanumeric special letters, at least 8 digits)

Step Seven: Set to allow remote login

Mysql does not allow remote login by default. We need to set it up and open the firewall to port 3306;

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'LCode1996.' WITH GRANT OPTION; Query OK, 0 rows affected, 1 warning (0.05 sec) mysql> exit; Bye
Copy after login

Exit;

[root@localhost ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent success [root@localhost ~]# firewall-cmd --reload success [root@localhost ~]#
Copy after login

Open port 3306

Step 8: Configure the default encoding to UTF-8

Modify the /etc/my.cnf configuration file and add it under [mysqld] Encoding configuration, as shown below:

[mysqld] character_set_server=utf8 init_connect='SET NAMES utf8' [root@localhost ~]# vi /etc/my.cnf
Copy after login

After editing and saving, restart the mysql service: systemctl restart mysqld

Check the encoding:

mysql> ; show variables like '%character%';

Step 9: Test

We use the local sqlyog remote connection Download mysql in the virtual machine

## At this point, Mysql installation and configuration is complete;

Related recommendations:

Mysql5.7 Detailed explanation of how to modify the data location under Windows 7

mysql5.7 detailed installation graphic process

MySQL Basic tutorial mysql5.7.18 installation and connection

The above is the detailed content of How to install and configure Mysql5.7 on Centos7. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!