centos7 install mysq5.7

Official website version 5.7: https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar
can be uploaded to Linux using xftp.
Create mysql installation directory

mkdir mysql

In order to avoid permission problems, give the maximum permission to the directory where the mysql unzip file is located

chmod -R 777 mysql

Use the tar command to unzip

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

Insert picture description here
Before installing the new version of mysql, you need to uninstall the mariadb-lib that comes with the system

rpm -qa|grep mariadb

Insert picture description here

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

Insert picture description here
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 packages

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 the installation process, add --force --nodeps at the end, which may be caused by yum installing an old version of GPG keys
Insert picture description here

rpm -ivh mysql-community-server-5.7.29-1.el7.x86_64.rpm --force --nodeps

Modify related configuration

vim /etc/my.cnf

Add these three lines
skip-grant-tables: skip login verification
character_set_server=utf8: set the default character set UTF-8
init_connect='SET NAMES utf8': set the default character set UTF-8

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

Insert picture description here
Set boot up

systemctl start mysqld.service

Start mysql

mysql -uroot

Set a simple password first

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

Insert picture description here
Effective immediately

flush privileges;

Insert picture description here
Exit mysql and stop mysql service

退出命令 quit
停止mysql 
systemctl stop  mysqld.service

Insert picture description here
Edit my.cnf configuration file to comment out the line skip-grant-tables
Restart the mysql service

systemctl start mysqld.service

Log in to mysql again

mysql -uroot -p123456

Enable remote access

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

This error was reported as a result:

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before

Using mysql 5.7, you need to modify the initial password in time, otherwise you will get an error in everything. Insert picture description here
If you want to set a simple test password, for example, set it to 123456, this error will be prompted. An error means that your password does not meet the requirements.

mysql> alter user 'root'@'localhost' identified by '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

This is actually related to the value of validate_password_policy.
The validate_password_policy has the following values: the
Insert picture description here
default is 1, which is MEDIUM, so the password set at the beginning must meet the length, and must contain numbers, lowercase or uppercase letters, and special characters.
Sometimes, just for my own testing, I don't want to set the password so complicated. For example, I just want to set the root password to 123456.
Two global parameters must be modified:

First, modify the value of the validate_password_policy parameter

mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)

The validate_password_length (password length) parameter defaults to 8, we modify it to 1

mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)

After completion, execute the modify password statement again to succeed

mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)

Settings take effect immediately

flush privileges;

Then set the remote access permission setting successfully

mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)

Guess you like

Origin blog.csdn.net/G_whang/article/details/111462535