Centos7安装mysql8无卡顿

网上很多安装步骤都会卡住所以决定自己再记录一下安装过程

MySQL :: Download MySQL Yum Repository

1.选择需要安装的版本

2.wget拼接刚刚复制的下载链接 

#下载安装包
wget  https://repo.mysql.com//mysql80-community-release-el7-11.noarch.rpm

#安装源信息
rpm -ivh mysql80-community-release-el7-11.noarch.rpm

#安装mysql
yum install mysql-server -y

3.初始化密码及远程连接 (步骤)

# 启动初始化密码
systemctl start mysqld

# 第一次启动后,可以查看mysql初始化密码
grep 'temporary password' /var/log/mysqld.log

#登录
mysql -u root -p

#默认的密码策略,需要:大写英文 + 特殊字符 + 数字
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root_123';

#配置远程
# 如果你的数据库是 mysql 8 及以上
# 1、进入数据库
use mysql;
# 2、修改user表
update user set host='%' where user='root';

# mysql 5.7 及之前,执行这行代码即可
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Root_123' WITH GRANT OPTION;

# 重载授权表
FLUSH PRIVILEGES;

# 退出
quit

# 重启
systemctl restart mysqld

实际操作 

[root@hecs-96341 ~]# wget https://repo.mysql.com//mysql80-community-release-el7-11.noarch.rpm
--2024-02-11 17:03:39--  https://repo.mysql.com//mysql80-community-release-el7-11.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.49.116.195, 2600:140b:c000:2af::1d68, 2600:140b:c000:2b0::1d68
Connecting to repo.mysql.com (repo.mysql.com)|23.49.116.195|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14064 (14K) [application/x-redhat-package-manager]
Saving to: ‘mysql80-community-release-el7-11.noarch.rpm’

100%[=======================================================================================>] 14,064      --.-K/s   in 0s      

2024-02-11 17:03:39 (475 MB/s) - ‘mysql80-community-release-el7-11.noarch.rpm’ saved [14064/14064]

[root@hecs-96341 ~]# ll
total 16
-rw-r--r-- 1 root root 14064 Oct 24 22:44 mysql80-community-release-el7-11.noarch.rpm
[root@hecs-96341 ~]# rpm -ivh mysql80-community-release-el7-11.noarch.rpm
warning: mysql80-community-release-el7-11.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql80-community-release-el7-11 ################################# [100%]
[root@hecs-96341 ~]# yum install mysql-server -y
Loaded plugins: fastestmirror
Determining fastest mirrors
base                                                                                                      | 3.6 kB  00:00:00     
epel                                                                                                      | 4.7 kB  00:00:00     
extras                                                                                                    | 2.9 kB  00:00:00     
mysql-connectors-community                                                                                | 2.6 kB  00:00:00     
mysql-tools-community                                                                                     | 2.6 kB  00:00:00     
mysql80-community                                                                                         | 2.6 kB  00:00:00     
updates                                                                                                   | 2.9 kB  00:00:00     
(1/10): base/7/x86_64/group_gz                                                                            | 153 kB  00:00:00     
(2/10): epel/x86_64/group_gz                                                                              | 100 kB  00:00:00     
(3/10): base/7/x86_64/primary_db                                                                          | 6.1 MB  00:00:00     
(4/10): epel/x86_64/updateinfo                                                                            | 1.0 MB  00:00:00     
(5/10): epel/x86_64/primary_db                                                                            | 7.0 MB  00:00:00     
(6/10): extras/7/x86_64/primary_db                                                                        | 250 kB  00:00:00     
(7/10): updates/7/x86_64/primary_db                                                                       |  25 MB  00:00:00     
(8/10): mysql-connectors-community/x86_64/primary_db                                                      | 109 kB  00:00:00     
(9/10): mysql80-community/x86_64/primary_db                                                               | 278 kB  00:00:02     
(10/10): mysql-tools-community/x86_64/primary_db                                                          |  98 kB  00:00:03     
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:8.0.36-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 8.0.36-1.el7 for package: mysql-community-server-8.0.36-1.el7.x86_64
--> Processing Dependency: mysql-community-icu-data-files = 8.0.36-1.el7 for package: mysql-community-server-8.0.36-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 8.0.11 for package: mysql-community-server-8.0.36-1.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: mysql-community-server-8.0.36-1.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: mysql-community-server-8.0.36-1.el7.x86_64
--> Processing Dependency: libaio.so.1()(64bit) for package: mysql-community-server-8.0.36-1.el7.x86_64
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
---> Package mysql-community-client.x86_64 0:8.0.36-1.el7 will be installed
--> Processing Dependency: mysql-community-client-plugins = 8.0.36-1.el7 for package: mysql-community-client-8.0.36-1.el7.x86_64
--> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.11 for package: mysql-community-client-8.0.36-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:8.0.36-1.el7 will be installed
---> Package mysql-community-icu-data-files.x86_64 0:8.0.36-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.68-1.el7 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
---> Package mysql-community-client-plugins.x86_64 0:8.0.36-1.el7 will be installed
---> Package mysql-community-libs.x86_64 0:8.0.36-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:8.0.36-1.el7 will be obsoleting
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================
 Package                                    Arch               Version                       Repository                     Size
=================================================================================================================================
Installing:
 mysql-community-libs                       x86_64             8.0.36-1.el7                  mysql80-community             1.5 M
     replacing  mariadb-libs.x86_64 1:5.5.68-1.el7
 mysql-community-libs-compat                x86_64             8.0.36-1.el7                  mysql80-community             669 k
     replacing  mariadb-libs.x86_64 1:5.5.68-1.el7
 mysql-community-server                     x86_64             8.0.36-1.el7                  mysql80-community              64 M
Installing for dependencies:
 libaio                                     x86_64             0.3.109-13.el7                base                           24 k
 mysql-community-client                     x86_64             8.0.36-1.el7                  mysql80-community              16 M
 mysql-community-client-plugins             x86_64             8.0.36-1.el7                  mysql80-community             3.5 M
 mysql-community-common                     x86_64             8.0.36-1.el7                  mysql80-community             665 k
 mysql-community-icu-data-files             x86_64             8.0.36-1.el7                  mysql80-community             2.2 M

Transaction Summary
=================================================================================================================================
Install  3 Packages (+5 Dependent packages)

Total download size: 89 M
Downloading packages:
(1/8): libaio-0.3.109-13.el7.x86_64.rpm                                                                   |  24 kB  00:00:00     
warning: /var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-client-plugins-8.0.36-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID a8d3785c: NOKEY
Public key for mysql-community-client-plugins-8.0.36-1.el7.x86_64.rpm is not installed
(2/8): mysql-community-client-plugins-8.0.36-1.el7.x86_64.rpm                                             | 3.5 MB  00:00:22     
(3/8): mysql-community-common-8.0.36-1.el7.x86_64.rpm                                                     | 665 kB  00:00:06     
(4/8): mysql-community-client-8.0.36-1.el7.x86_64.rpm                                                     |  16 MB  00:00:50     
(5/8): mysql-community-icu-data-files-8.0.36-1.el7.x86_64.rpm                                             | 2.2 MB  00:00:24     
(6/8): mysql-community-libs-8.0.36-1.el7.x86_64.rpm                                                       | 1.5 MB  00:00:05     
(7/8): mysql-community-libs-compat-8.0.36-1.el7.x86_64.rpm                                                | 669 kB  00:00:09     
(8/8): mysql-community-server-8.0.36-1.el7.x86_64.rpm                                                     |  64 MB  00:09:13     
---------------------------------------------------------------------------------------------------------------------------------
Total                                                                                            149 kB/s |  89 MB  00:10:10     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2023
Importing GPG key 0xA8D3785C:
 Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 Fingerprint: bca4 3417 c3b4 85dd 128e c6d4 b7b3 b788 a8d3 785c
 Package    : mysql80-community-release-el7-11.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2023
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
Importing GPG key 0x3A79BD29:
 Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 Fingerprint: 859b e8d7 c586 f538 430b 19c2 467b 942d 3a79 bd29
 Package    : mysql80-community-release-el7-11.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 Package    : mysql80-community-release-el7-11.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : mysql-community-common-8.0.36-1.el7.x86_64                                                                    1/9 
  Installing : mysql-community-client-plugins-8.0.36-1.el7.x86_64                                                            2/9 
  Installing : mysql-community-libs-8.0.36-1.el7.x86_64                                                                      3/9 
  Installing : mysql-community-client-8.0.36-1.el7.x86_64                                                                    4/9 
  Installing : libaio-0.3.109-13.el7.x86_64                                                                                  5/9 
  Installing : mysql-community-icu-data-files-8.0.36-1.el7.x86_64                                                            6/9 
  Installing : mysql-community-server-8.0.36-1.el7.x86_64                                                                    7/9 
  Installing : mysql-community-libs-compat-8.0.36-1.el7.x86_64                                                               8/9 
  Erasing    : 1:mariadb-libs-5.5.68-1.el7.x86_64                                                                            9/9 
  Verifying  : mysql-community-client-8.0.36-1.el7.x86_64                                                                    1/9 
  Verifying  : mysql-community-client-plugins-8.0.36-1.el7.x86_64                                                            2/9 
  Verifying  : mysql-community-server-8.0.36-1.el7.x86_64                                                                    3/9 
  Verifying  : mysql-community-common-8.0.36-1.el7.x86_64                                                                    4/9 
  Verifying  : mysql-community-libs-8.0.36-1.el7.x86_64                                                                      5/9 
  Verifying  : mysql-community-icu-data-files-8.0.36-1.el7.x86_64                                                            6/9 
  Verifying  : libaio-0.3.109-13.el7.x86_64                                                                                  7/9 
  Verifying  : mysql-community-libs-compat-8.0.36-1.el7.x86_64                                                               8/9 
  Verifying  : 1:mariadb-libs-5.5.68-1.el7.x86_64                                                                            9/9 

Installed:
  mysql-community-libs.x86_64 0:8.0.36-1.el7                   mysql-community-libs-compat.x86_64 0:8.0.36-1.el7                
  mysql-community-server.x86_64 0:8.0.36-1.el7                

Dependency Installed:
  libaio.x86_64 0:0.3.109-13.el7                                      mysql-community-client.x86_64 0:8.0.36-1.el7               
  mysql-community-client-plugins.x86_64 0:8.0.36-1.el7                mysql-community-common.x86_64 0:8.0.36-1.el7               
  mysql-community-icu-data-files.x86_64 0:8.0.36-1.el7               

Replaced:
  mariadb-libs.x86_64 1:5.5.68-1.el7                                                                                             

Complete!
[root@hecs-96341 ~]# systemctl start mysqld
[root@hecs-96341 ~]# grep 'temporary password' /var/log/mysqld.log
2024-02-11T09:16:15.083280Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: wYcU9ZH/si.u
[root@hecs-96341 ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.36

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

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> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root_123';
Query OK, 0 rows affected (0.01 sec)

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[root@hecs-96341 ~]# systemctl restart mysqld

[root@hecs-96341 ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.36 MySQL Community Server - GPL

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值