A, preparation,

View the Linux version information

uname -a
Copy the code

Uninstall Mariadb that comes with Linux7

# Check the package
rpm -qa | grep mariadb

# Uninstall related packagesRPM -e check out the package name, there are dependencies to delete together on the lineCopy the code

Download related packages

Downloads.mysql.com/archives/co…

Second, the installation

Installation package for writing articles

upload

Upload the downloaded package to the server

The RPM installation

The order is listed. Don’t be wrong

RPM RPM -ivh mysql-community-common-8.0.23-1.el7.x86_64. RPM RPM -ivh mysql-community-client-plugins-8.0.23-1.el7.x86_64. RPM RPM RPM -ivh mysql-community-libs-8.0.23-1.el7.x86_64. RPM RPM -ivh mysql-community-client-8.0.23-1.el7.x86_64. RPM Mysql - community - server - 8.0.23-1. El7. X86_64. RPMCopy the code

check

mysqladmin --version
Copy the code

Three, start,

configuration

The default dataDir does not match. Need to modify

vim /etc/my.cnf
Copy the code
datadir=/var/lib/mysql/mysql
Copy the code

Start the

systemctl start mysqld
Copy the code
systemctl status mysqld
Copy the code

4. Change the password

Viewing the Default Password

 cat /var/log/mysqld.log | grep password

Copy the code

The login

mysql -u root -p
Copy the code

Temporarily change the password that meets the rule

alter user root@localhost identified by 'Root_123456';

Copy the code

Changing a Password Policy

SHOW VARIABLES LIKE 'validate_password%';

Copy the code

set global validate_password.policy = low;
set global validate_password.length = 4; 
Copy the code
alter user root@localhost identified by '123456';
Copy the code
update user set host=The '%' where host='localhost';
Copy the code
systemctl restart mysqld; 
Copy the code