【mysql】 手把手教你安装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

下载

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

安装

  1. 离线服务器下载后放到服务器上,联网服务器直接使用命令下载:
wget https://dev.mysql.***/get/mysql-8.0.36-1.el7.x86_64.rpm-bundle.tar
  1. 对压缩包进行解压
[root@VM-16-11-centos mysqls]# tar -xvf mysql-8.0.36-1.el7.x86_64.rpm-bundle.tar 
mysql-***munity-client-8.0.36-1.el7.x86_64.rpm
mysql-***munity-client-plugins-8.0.36-1.el7.x86_64.rpm
mysql-***munity-***mon-8.0.36-1.el7.x86_64.rpm
mysql-***munity-debuginfo-8.0.36-1.el7.x86_64.rpm
mysql-***munity-devel-8.0.36-1.el7.x86_64.rpm
mysql-***munity-embedded-***pat-8.0.36-1.el7.x86_64.rpm
mysql-***munity-icu-data-files-8.0.36-1.el7.x86_64.rpm
mysql-***munity-libs-8.0.36-1.el7.x86_64.rpm
mysql-***munity-libs-***pat-8.0.36-1.el7.x86_64.rpm
mysql-***munity-server-8.0.36-1.el7.x86_64.rpm
mysql-***munity-server-debug-8.0.36-1.el7.x86_64.rpm
mysql-***munity-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-***munity-client-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415    3621168 Dec 14 14:42 mysql-***munity-client-plugins-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415     681264 Dec 14 14:42 mysql-***munity-***mon-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415  528659552 Dec 14 14:43 mysql-***munity-debuginfo-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415    1948160 Dec 14 14:44 mysql-***munity-devel-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415    4217212 Dec 14 14:44 mysql-***munity-embedded-***pat-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415    2344468 Dec 14 14:44 mysql-***munity-icu-data-files-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415    1563732 Dec 14 14:44 mysql-***munity-libs-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415     685408 Dec 14 14:44 mysql-***munity-libs-***pat-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   67429872 Dec 14 14:44 mysql-***munity-server-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   25664528 Dec 14 14:45 mysql-***munity-server-debug-8.0.36-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415  376818184 Dec 14 14:47 mysql-***munity-test-8.0.36-1.el7.x86_64.rpm

截图如下:

3. 安装解压出来的rpm安装包。如下:

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

截图如下:
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.***/doc/refman/en/using-systemd.html
[root@VM-16-11-centos mysqls]# 

截图如下:

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.***/doc/refman/en/using-systemd.html
  Process: 21984 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SU***ESS)
 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]# 

截图如下:

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 ***munity 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

截图如下:

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

[root@VM-16-11-centos ~]# mysql -u root -p 
Enter password: 
Wel***e to the MySQL monitor.  ***mands 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. 基于以上,mysql安装完成!烨!✌

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

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

截图如下:

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

[root@VM-16-11-centos ~]# vim /etc/my.***f

截图如下:

问题集锦

  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';

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

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

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

转载请说明出处内容投诉
CSS教程_站长资源网 » 【mysql】 手把手教你安装mysql-8.0.36数据库

发表评论

欢迎 访客 发表评论

一个令你着迷的主题!

查看演示 官网购买