Linux system installation MySQL8.0 version

insert image description here

1. Introduction to MySQL

1.1 Introduction to MySQL

MySQL 8.0 is the latest version of the MySQL database management system, a relational database management system developed and maintained by Oracle Corporation. MySQL 8.0 brings a host of new features, including multiple performance improvements, better security and scalability, and new management capabilities.

1.2 MySQL Features

  • Better performance: MySQL 8.0 provides better performance support for large queries and transaction processing. It introduces new index types, such as hash indexes, to provide faster query operations.

  • Better security: MySQL 8.0 introduces better password validation rules to ensure the security of user accounts. It also supports stronger encryption such as TLS and SSL. Additionally, it provides better access control mechanisms such as role-based access control.

  • Better scalability: MySQL 8.0 introduces a new data dictionary architecture, which uses a more efficient memory table to cache table metadata information to improve performance.

  • New management features: MySQL 8.0 introduces new management features such as InnoDB integrated full-text search, better online DDL and JSON support.

2. Introduction to this practice

2.1 Environmental planning

This practice environment is a personal test environment, and the operating system used is centos7.6.

hostname IP address system version kernel version mysql version
jeven 192.168.3.166 centos7.6 3.10.0-957.el7.x86_64 mysql8.0.34

2.2 Purpose of this practice

1. Install MySQL8.0 version under centos7.6 system.
2. You can log in to the mysql database remotely.

3. Uninstall the mariadb database

3.1 Uninstall the mariadb database

If the maraidb database has been installed on the system, mariadb needs to be uninstalled

yum remove mariadb* -y
rm -rf /etc/my.cnf
rm -rf /var/lib/mysql/

3.2 Uninstall mysql database

If other versions of mysql have been installed in the system, uninstall and clear the environment in advance.


rpm -e mysql  // 普通删除模式
rpm -e --nodeps mysql  // 强力删除模式,
rm -rf /etc/my.cnf
rm -rf /var/lib/mysql/

Fourth, configure the yum warehouse

4.1 Download the rpm file

Download mysql80-community-release-el7-7.noarch.rpm

wget https://repo.mysql.com//mysql80-community-release-el7-7.noarch.rpm

insert image description here

4.2 Configure yum warehouse

Configure the yum warehouse of mysql

 sudo rpm -Uvh mysql80-community-release-el7-7.noarch.rpm

insert image description here

4.3 Check the yum warehouse status

Check yum repository status

[root@jeven ~]# yum repolist all |grep enable
base/7/x86_64                                CentOS-7 - Base - m enabled: 10,072
extras/7/x86_64                              CentOS-7 - Extras - enabled:    518
mysql-connectors-community/x86_64            MySQL Connectors Co enabled:    227
mysql-tools-community/x86_64                 MySQL Tools Communi enabled:    100
mysql80-community/x86_64                     MySQL 8.0 Community enabled:    424
updates/7/x86_64                             CentOS-7 - Updates  enabled:  5,061

4.4 Check mysql version

Check mysql default installation version

[root@jeven ~]# yum repolist enabled | grep mysql
mysql-connectors-community/x86_64 MySQL Connectors Community                 227
mysql-tools-community/x86_64      MySQL Tools Community                      100
mysql80-community/x86_64          MySQL 8.0 Community Server                 424

Five, install MySQL8.0

5.1 install mysql

Install mysql directly using yum

yum install mysql-community-server -y

insert image description here

5.2 Start mysql service

Start the mysql service and set it to start automatically.

 systemctl enable --now mysqld

5.3 Check mysql service status

Check mysql service status

[root@jeven ~]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2023-07-23 19:37:31 CST; 35s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 117898 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 117971 (mysqld)
   Status: "Server is operational"
    Tasks: 38
   Memory: 472.2M
   CGroup: /system.slice/mysqld.service
           └─117971 /usr/sbin/mysqld

Jul 23 19:37:21 jeven systemd[1]: Starting MySQL Server...
Jul 23 19:37:31 jeven systemd[1]: Started MySQL Server.

Six, the initial configuration of mysql

6.1 Get login password

Obtain a randomly generated login password

[root@jeven ~]# grep 'temporary password' /var/log/mysqld.log
2023-07-23T11:37:25.670116Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Sw#rsuaMh4(I

6.2 Log in to mysql locally

Use the generated random password locally to log in to mysql.

mysql -uroot -p

insert image description here

6.3 Modify local user password

Modify the password of the local user 'root'@'localhost'

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root.36#336';

insert image description here

6.4 Create a new remote login user

  • Set the security strength of a user's password policy
set global validate_password.policy=LOW;
  • Set the password length to not less than 4
set global validate_password.length=4;
  • View password policy
SHOW VARIABLES LIKE 'validate_password%';

insert image description here

  • new user
create user 'admin'@'%' identified WITH mysql_native_password BY 'admin';
grant all on *.* to  'admin'@'%'    with GRANT OPTION;
flush privileges;

Seven, remote login mysql

Log in to mysql remotely from other mysql clients

[root@server ~]# mysql -h 192.168.3.166 -uadmin -padmin
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 8.0.34 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Guess you like

Origin blog.csdn.net/jks212454/article/details/131882628