编程知识 cdmana.com

Centos7 install MySQL (complete)

One 、 Download installation package

Official website 5.7 edition :https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar

Two 、 install

Use tar Command decompression

tar -xvf mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar

Install new version mysql front , The system's own mariadb-lib uninstall

rpm -qa|grep mariadb

mariadb-libs-5.5.60-1.el7_5.x86_64 Delete the mariadb

rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64

To avoid permission problems , to mysql Decompress the directory where the file is located

chmod -R 777 mysql

Install in strict order :mysql-community-common-5.7.29-1.el7.x86_64.rpm、mysql-community-libs-5.7.29-1.el7.x86_64.rpm、mysql-community-client-5.7.29-1.el7.x86_64.rpm、mysql-community-server-5.7.29-1.el7.x86_64.rpm These four bags

rpm -ivh mysql-community-common-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.29-1.el7.x86_64.rpm

If this error occurs during installation, add --force --nodeps, This may be due to yum An older version of GPG keys Caused by the

3、 ... and 、 Configuration database

vim /etc/my.cnf

Add these three lines

skip-grant-tables
character_set_server=utf8
init_connect='SET NAMES utf8'

skip-grant-tables: Skip login verification character_set_server=utf8: Set default character set UTF-8 init_connect=‘SET NAMES utf8’: Set default character set UTF-8

Four 、 start-up mysql service

Set boot up

systemctl start mysqld.service

start-up mysq

mysql

5、 ... and 、 Set password and turn on remote login

5.1 Set a simple password first

update mysql.user set authentication_string=password('123456') where user='root';

Immediate effect

flush privileges;

sign out mysql And stop mysql service

systemctl stop  mysqld.service

edit my.cnf The configuration file will :skip-grant-tables Comment out this line

restart mysql service

systemctl start mysqld.service

Log in again mysql

mysql -uroot -p123456

Enter the command error and then execute the password reset

set password=password('123456');

5.2 Set password policy ( This step can be skipped )

If you want to set a simpler password, you need to set a password policy , Otherwise, setting a simple password will make a mistake Check password policy

 SHOW VARIABLES LIKE 'validate_password%'; 

1)、validate_password_length Total fixed length password ; 2)、validate_password_dictionary_file Specify the file path for password verification ; 3)、validate_password_mixed_case_count The whole password should contain at least large / The total number of lowercase letters ; 4)、validate_password_number_count The whole password must contain at least the number of Arabic numerals ; 5)、validate_password_policy Specify the strength verification level of the password , The default is MEDIUM;

Set the password authentication level , Set up validate_password_policy The global parameter of is LOW

set global validate_password_policy=LOW;

As long as the length of the set password is less than 3 , Will be automatically set to 4

 set global validate_password_length=4;

5.3 Open ports

to open up 3306 port

firewall-cmd --zone=public --add-port=3306/tcp --permanent

–zone # Scope –add-port=80/tcp # Add port , The format is : port / Communication protocol –permanent # permanent , Failure after restart without this parameter

service iptables restart

firewall-cmd --reload

5.4 Turn on remote login

grant all privileges on *.* to 'root'@'%' identified by '123123' with grant option;

by The following is the remote login password , Remote login password can be different from user password

6、 ... and 、 Reference resources

CSDN:https://blog.csdn.net/HM_1011000000/article/details/92831688 CSDN:https://blog.csdn.net/hello_world_qwp/article/details/79551789

Participation of this paper Tencent cloud media sharing plan , You are welcome to join us , share .

版权声明
本文为[The blank of writing memory]所创,转载请带上原文链接,感谢
https://cdmana.com/2020/12/20201224104023969L.html

Scroll to Top