当前位置:   article > 正文

【mysql】 手把手教你安装mysql-8.0.36数据库_mysql8.0.36

mysql8.0.36

手把手教你安装mysql-8.0.36数据库

过了个周末,舒舒服服,把家里捣鼓了下,自己编了一个网格照片墙,把来做客的家具都安排好位置,今天,继续上班啦。

环境

开始之前,老生常谈,首先看看我服务器的信息:

[root@VM-16-11-centos ~]# uname -a
Linux VM-16-11-centos 3.10.0-1160.99.1.el7.x86_64 #1 SMP Wed Sep 13 14:19:20 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
  • 1
  • 2

下载

虽然每次写MySQL教程都会写下载链接,这次依然附带上。提供两种方式下载,
** 下载地址:**直接下载mysql数据库tar格式,官网下载地址
** 下载页面:**在页面找自己想要的版本进行安装,官网下载页面

安装

  1. 离线服务器下载后放到服务器上,联网服务器直接使用命令下载:
wget https://dev.mysql.com/get/mysql-8.0.36-1.el7.x86_64.rpm-bundle.tar
  • 1
  1. 对压缩包进行解压
[root@VM-16-11-centos mysqls]# tar -xvf mysql-8.0.36-1.el7.x86_64.rpm-bundle.tar 
mysql-community-client-8.0.36-1.el7.x86_64.rpm
mysql-community-client-plugins-8.0.36-1.el7.x86_64.rpm
mysql-community-common-8.0.36-1.el7.x86_64.rpm
mysql-community-debuginfo-8.0.36-1.el7.x86_64.rpm
mysql-community-devel-8.0.36-1.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.36-1.el7.x86_64.rpm
mysql-community-icu-data-files-8.0.36-1.el7.x86_64.rpm
mysql-community-libs-8.0.36-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.36-1.el7.x86_64.rpm
mysql-community-server-8.0.36-1.el7.x86_64.rpm
mysql-community-server-debug-8.0.36-1.el7.x86_64.rpm
mysql-community-test-8.0.36-1.el7.x86_64.rpm
[root@VM-16-11-centos mysqls]# ll
total 2012556
-rw-r--r-- 1 root root  1030420480 Dec 14 14:56 mysql-8.0.36-1.el7.x86_64.rpm-bundle.tar
-rw-r--r-- 1 7155 31415   16767208 Dec 14 14:42 mysql-community-client-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415    3621168 Dec 14 14:42 mysql-community-client-plugins-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415     681264 Dec 14 14:42 mysql-community-common-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415  528659552 Dec 14 14:43 mysql-community-debuginfo-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415    1948160 Dec 14 14:44 mysql-community-devel-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415    4217212 Dec 14 14:44 mysql-community-embedded-compat-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415    2344468 Dec 14 14:44 mysql-community-icu-data-files-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415    1563732 Dec 14 14:44 mysql-community-libs-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415     685408 Dec 14 14:44 mysql-community-libs-compat-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   67429872 Dec 14 14:44 mysql-community-server-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   25664528 Dec 14 14:45 mysql-community-server-debug-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415  376818184 Dec 14 14:47 mysql-community-test-8.0.36-1.el7.x86_64.rpm
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28

截图如下:
在这里插入图片描述
3. 安装解压出来的rpm安装包。如下:

[root@VM-16-11-centos mysqls]# rpm  -ivh  *.rpm --nodeps --force
warning: mysql-community-client-8.0.36-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID a8d3785c: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-common-8.0.36-1.e################################# [  8%]
   2:mysql-community-client-plugins-8.################################# [ 17%]
   3:mysql-community-libs-8.0.36-1.el7################################# [ 25%]
   4:mysql-community-client-8.0.36-1.e################################# [ 33%]
   5:mysql-community-icu-data-files-8.################################# [ 42%]
   6:mysql-community-server-8.0.36-1.e################################# [ 50%]
   7:mysql-community-server-debug-8.0.################################# [ 58%]
   8:mysql-community-test-8.0.36-1.el7################################# [ 67%]
   9:mysql-community-devel-8.0.36-1.el################################# [ 75%]
  10:mysql-community-libs-compat-8.0.3################################# [ 83%]
  11:mysql-community-embedded-compat-8################################# [ 92%]
  12:mysql-community-debuginfo-8.0.36-################################# [100%]
[root@VM-16-11-centos mysqls]# 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

截图如下: 在这里插入图片描述
4. 使用命令查看安装是否成功,如下:

[root@VM-16-11-centos mysqls]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
[root@VM-16-11-centos mysqls]# 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

截图如下:
在这里插入图片描述
5. 启动mysql服务,如下:

[root@VM-16-11-centos mysqls]# systemctl status mysqld                                                                     
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2024-03-04 16:59:31 CST; 6s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 21984 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 22106 (mysqld)
   Status: "Server is operational"
    Tasks: 38
   Memory: 513.4M
   CGroup: /system.slice/mysqld.service
           └─22106 /usr/sbin/mysqld

Mar 04 16:59:18 VM-16-11-centos systemd[1]: Starting MySQL Server...
Mar 04 16:59:31 VM-16-11-centos systemd[1]: Started MySQL Server.
[root@VM-16-11-centos mysqls]# 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

截图如下:
在这里插入图片描述
6. 查看数据库密码,和往常一样依然是随机密码,有日志可知本次密码为k*;2bsNU)&Oo,如下:

2024-03-04T08:59:22.920568Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.36) initializing of server in progress as process 22031
2024-03-04T08:59:22.949805Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-03-04T08:59:23.861796Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-03-04T08:59:26.000382Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: k*;2bsNU)&Oo
2024-03-04T08:59:31.115096Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.36) starting as process 22106
2024-03-04T08:59:31.131318Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-03-04T08:59:31.335613Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-03-04T08:59:31.639123Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2024-03-04T08:59:31.639170Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2024-03-04T08:59:31.672087Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.36'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server - GPL.
2024-03-04T08:59:31.672090Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

截图如下:

在这里插入图片描述

7.测试数据库链接,命令如下:

[root@VM-16-11-centos ~]# 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> 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

截图如下:
在这里插入图片描述

  1. 基于以上,mysql安装完成!烨!✌

可以连接以后,记得修改密码,命令:

ALTER USER USER() IDENTIFIED BY 'Root@123';
  • 1

截图如下:
在这里插入图片描述

如果有修改配置文件的需求,使用以下命令修改配置文件,修改后重启生效

[root@VM-16-11-centos ~]# vim /etc/my.cnf
  • 1

截图如下:
在这里插入图片描述

问题集锦

  1. 修改密码时报错:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
    解决方案:
    意思是密码强度不够,试试大小写数字加符号。
    或者执行以下命令后重试:
#查看密码配置
show variables like 'validate_password%';
#设置密码强度
SET GLOBAL validate_password.policy=LOW;  
SET GLOBAL validate_password.length=0;  
SET GLOBAL validate_password.mixed_case_count=0;  
SET GLOBAL validate_password.number_count=0;  
SET GLOBAL validate_password.special_char_count=0;

FLUSH PRIVILEGES;

ALTER USER USER() IDENTIFIED BY 'iceter';
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

修改成功,注意:不要修改成关键字,比如:root,依然会报错。

  1. 安装时候报错:error: unpacking of archive failed: cpio: Bad magic
    解决方案:
    查看mysql版本与Linux系统版本是否一致。重新下载版本一致的进行安装即可。

蜚语:自己捣鼓自己的房子,就是有一种莫名的成就感,哈哈哈,想朔朔的第n+1天,想媳妇的每一天~~~

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/291882
推荐阅读
相关标签
  

闽ICP备14008679号