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

打印 上一主题 下一主题

主题 558|帖子 558|积分 1674



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

开始之前,老生常谈,起首看看我服务器的信息:
  1. [root@VM-16-11-centos ~]# uname -a
  2. 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.com/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
  2. mysql-community-client-8.0.36-1.el7.x86_64.rpm
  3. mysql-community-client-plugins-8.0.36-1.el7.x86_64.rpm
  4. mysql-community-common-8.0.36-1.el7.x86_64.rpm
  5. mysql-community-debuginfo-8.0.36-1.el7.x86_64.rpm
  6. mysql-community-devel-8.0.36-1.el7.x86_64.rpm
  7. mysql-community-embedded-compat-8.0.36-1.el7.x86_64.rpm
  8. mysql-community-icu-data-files-8.0.36-1.el7.x86_64.rpm
  9. mysql-community-libs-8.0.36-1.el7.x86_64.rpm
  10. mysql-community-libs-compat-8.0.36-1.el7.x86_64.rpm
  11. mysql-community-server-8.0.36-1.el7.x86_64.rpm
  12. mysql-community-server-debug-8.0.36-1.el7.x86_64.rpm
  13. mysql-community-test-8.0.36-1.el7.x86_64.rpm
  14. [root@VM-16-11-centos mysqls]# ll
  15. total 2012556
  16. -rw-r--r-- 1 root root  1030420480 Dec 14 14:56 mysql-8.0.36-1.el7.x86_64.rpm-bundle.tar
  17. -rw-r--r-- 1 7155 31415   16767208 Dec 14 14:42 mysql-community-client-8.0.36-1.el7.x86_64.rpm
  18. -rw-r--r-- 1 7155 31415    3621168 Dec 14 14:42 mysql-community-client-plugins-8.0.36-1.el7.x86_64.rpm
  19. -rw-r--r-- 1 7155 31415     681264 Dec 14 14:42 mysql-community-common-8.0.36-1.el7.x86_64.rpm
  20. -rw-r--r-- 1 7155 31415  528659552 Dec 14 14:43 mysql-community-debuginfo-8.0.36-1.el7.x86_64.rpm
  21. -rw-r--r-- 1 7155 31415    1948160 Dec 14 14:44 mysql-community-devel-8.0.36-1.el7.x86_64.rpm
  22. -rw-r--r-- 1 7155 31415    4217212 Dec 14 14:44 mysql-community-embedded-compat-8.0.36-1.el7.x86_64.rpm
  23. -rw-r--r-- 1 7155 31415    2344468 Dec 14 14:44 mysql-community-icu-data-files-8.0.36-1.el7.x86_64.rpm
  24. -rw-r--r-- 1 7155 31415    1563732 Dec 14 14:44 mysql-community-libs-8.0.36-1.el7.x86_64.rpm
  25. -rw-r--r-- 1 7155 31415     685408 Dec 14 14:44 mysql-community-libs-compat-8.0.36-1.el7.x86_64.rpm
  26. -rw-r--r-- 1 7155 31415   67429872 Dec 14 14:44 mysql-community-server-8.0.36-1.el7.x86_64.rpm
  27. -rw-r--r-- 1 7155 31415   25664528 Dec 14 14:45 mysql-community-server-debug-8.0.36-1.el7.x86_64.rpm
  28. -rw-r--r-- 1 7155 31415  376818184 Dec 14 14:47 mysql-community-test-8.0.36-1.el7.x86_64.rpm
复制代码
截图如下:

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

4. 使用下令查看安装是否乐成,如下:
  1. [root@VM-16-11-centos mysqls]# systemctl status mysqld
  2. ● mysqld.service - MySQL Server
  3.    Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
  4.    Active: inactive (dead)
  5.      Docs: man:mysqld(8)
  6.            http://dev.mysql.com/doc/refman/en/using-systemd.html
  7. [root@VM-16-11-centos mysqls]#
复制代码
截图如下:

5. 启动mysql服务,如下:
  1. [root@VM-16-11-centos mysqls]# systemctl status mysqld                                                                     
  2. ● mysqld.service - MySQL Server
  3.    Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
  4.    Active: active (running) since Mon 2024-03-04 16:59:31 CST; 6s ago
  5.      Docs: man:mysqld(8)
  6.            http://dev.mysql.com/doc/refman/en/using-systemd.html
  7.   Process: 21984 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
  8. Main PID: 22106 (mysqld)
  9.    Status: "Server is operational"
  10.     Tasks: 38
  11.    Memory: 513.4M
  12.    CGroup: /system.slice/mysqld.service
  13.            └─22106 /usr/sbin/mysqld
  14. Mar 04 16:59:18 VM-16-11-centos systemd[1]: Starting MySQL Server...
  15. Mar 04 16:59:31 VM-16-11-centos systemd[1]: Started MySQL Server.
  16. [root@VM-16-11-centos mysqls]#
复制代码
截图如下:

6. 查看数据库密码,和往常一样依然是随机密码,有日志可知本次密码为k*;2bsNU)&Oo,如下:
  1. 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
  2. 2024-03-04T08:59:22.949805Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
  3. 2024-03-04T08:59:23.861796Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
  4. 2024-03-04T08:59:26.000382Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: k*;2bsNU)&Oo
  5. 2024-03-04T08:59:31.115096Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.36) starting as process 22106
  6. 2024-03-04T08:59:31.131318Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
  7. 2024-03-04T08:59:31.335613Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
  8. 2024-03-04T08:59:31.639123Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
  9. 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.
  10. 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.
  11. 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.测试数据库链接,下令如下:
  1. [root@VM-16-11-centos ~]# mysql -u root -p
  2. Enter password:
  3. Welcome to the MySQL monitor.  Commands end with ; or \g.
  4. Your MySQL connection id is 8
  5. Server version: 8.0.36
  6. Copyright (c) 2000, 2024, Oracle and/or its affiliates.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. mysql>
复制代码
截图如下:


  • 基于以上,mysql安装完成!烨!✌
可以毗连以后,记得修改密码,下令:
  1. ALTER USER USER() IDENTIFIED BY 'Root@123';
复制代码
截图如下:

如果有修改配置文件的需求,使用以下下令修改配置文件,修改后重启生效:
  1. [root@VM-16-11-centos ~]# vim /etc/my.cnf
复制代码
截图如下:

问题集锦


  • 修改密码时报错:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
    解决方案:
    意思是密码强度不敷,试试大小写数字加符号。
    或者执行以下下令后重试:
  1. #查看密码配置
  2. show variables like 'validate_password%';
  3. #设置密码强度
  4. SET GLOBAL validate_password.policy=LOW;  
  5. SET GLOBAL validate_password.length=0;  
  6. SET GLOBAL validate_password.mixed_case_count=0;  
  7. SET GLOBAL validate_password.number_count=0;  
  8. SET GLOBAL validate_password.special_char_count=0;
  9. FLUSH PRIVILEGES;
  10. ALTER USER USER() IDENTIFIED BY 'iceter';
复制代码
修改乐成,注意:不要修改成关键字,比如:root,依然会报错。

  • 安装时间报错:error: unpacking of archive failed: cpio: Bad magic
    解决方案:
    查看mysql版本与Linux体系版本是否一致。重新下载版本一致的举行安装即可。
蜚语:自己捣鼓自己的房子,就是有一种莫名的成绩感,哈哈哈,想朔朔的第n+1天,想媳妇的每一天~~~

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

圆咕噜咕噜

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表