Centos7 installs mysql8 (two installation methods)

Centos7 installation mysql8 (two installation methods) super detailed

1, Command installation

1. Configure Mysql 8.0 installation source: rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm

[root@localhost home]# rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
 obtain https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
 Warning:/var/tmp/rpm-tmp.HgXxlP: head V3 DSA/SHA1 Signature, secret key ID 5072e1f5: NOKEY
 In preparation...                          ################################# [100%]
Upgrading/install...
   1:mysql80-community-release-el7-1  ################################# [100%]
[root@localhost home]# 

2. Install Mysql 8.0: Yum -- enablerepo = mysql80 community install MySQL community server

yum --enablerepo=mysql80-community install mysql-community-server

Install 3 packages (+3 Dependent packages)
Total downloads: 490 M
Is this ok [y/d/N]: y    
Prompt for input appears y that will do

3. Select y below

Is this ok [y/d/N]:y
complete
 notice complete The installation is finished

3. Start mysql service

service mysqld start

4. Check the operation status:

service mysqld status

4. Check the temporary root password:

[root@localhost home]# grep "A temporary password" /var/log/mysqld.log
2021-08-10T10:03:56.760945Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: =kKRWb.Vy7OP

5. Change temporary password:
The first thing is to change it so that I can easily remember the password. First log in to mysql with a temporary password
Enter: mysql -uroot -p copy the password you just viewed and log in

[root@localhost hyh]# mysql -u root -p
Enter password:Enter the password later. Note that you can't see it when you enter the password. Just enter after entering.

If you want to view the complete initial password rules of MySQL, execute the following command after logging in:

SHOW VARIABLES LIKE 'validate_password%';

1-validate_password.length is the minimum length of the password. The default is 8. We change it to 4

mysql> set global validate_password.length=4;

2-validate_password.policy the complexity of the verification password. We change it to 0

mysql> set global validate_password.policy=0;

3-validate_password.check_user_name check the user name. The user name and password cannot be the same. We also remove it

mysql> set global validate_password.check_user_name=off;

Now execute the command to change the password:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '1234';

reconfigure remote access

The mysql client connection reports an error that connection is not allowed because the remote access permission is not opened
The host of root is localhost, not% Oh, let's add a root account with host% as follows:

CREATE USER 'root'@'%' IDENTIFIED BY 'root';

Then execute:

GRANT ALL ON *.* TO 'root'@'%'; 

7. Connect mysql with navicat. If you connect mysql with navicat, you will still report an error:
The reason is that the encryption rules of mysql8 are different. It is caching_sha2_password
Change the encryption method to MySQL_ native_ Just password:

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '1234';

The encryption method has been changed to mysql_native_password: (connection succeeded)!!!

Note: if the connection fails, your firewall is open, or port 3306 is not open
Close the firewall and open port 3306. The connection is successful!!!

MySQL startup:

systemctl enable mysqld.service

Delete the system's own database: uninstall the original mariadb

rpm -qa | grep mariadb                               query
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64   delete

2, Download and install Mysql on the official website

Download from Mysql official website: https://dev.mysql.com/downloads/mysql/

1. Upload the rz command to the / home directory

[root@localhost ~]# rz

2 decompression

[root@localhost home]# tar -zxvf mysql-8.0.21-1.el7.x86_64.rpm-bundle.tar

3. Close selinux:

setenforce 0
vim /etc/selinux/config
 take SELINUX=enforcing Change to SELINUX=disabled

4. Delete the system's own database:

rpm -qa | grep mariadb
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64

5. Install MySQL 8 data:

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

6 initialize the database:

mysqld --initialize --console --user=mysql
chown -R mysql:mysql /home/huimou/mysql

7 start database

systemctl start mysqld

8. Set database self startup

systemctl enable mysqld.service

9. View the initial password of the database

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

Later, modify the password, configure remote access, and set the boot auto start, which is the same as the above case!!!

Keywords: Linux Database MySQL CentOS mysql8

Added by WebDesEyen on Mon, 03 Jan 2022 03:28:44 +0200