圆咕噜咕噜 发表于 2024-8-8 07:39:36

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



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

开始之前,老生常谈,起首看看我服务器的信息:
# 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格式,官网下载地址
** 下载页面:**在页面找自己想要的版本举行安装,官网下载页面
安装


[*]离线服务器下载后放到服务器上,联网服务器直接使用下令下载:
wget https://dev.mysql.com/get/mysql-8.0.36-1.el7.x86_64.rpm-bundle.tar

[*]对压缩包举行解压
# 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
# ll
total 2012556
-rw-r--r-- 1 root root1030420480 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 31415528659552 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 31415376818184 Dec 14 14:47 mysql-community-test-8.0.36-1.el7.x86_64.rpm
截图如下:
https://i-blog.csdnimg.cn/blog_migrate/ec6e8216c1f7f99910979c7340fd1d39.png
3. 安装解压出来的rpm安装包。如下:
# 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...                        #################################
Updating / installing...
   1:mysql-community-common-8.0.36-1.e#################################
   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-#################################
#
截图如下: https://i-blog.csdnimg.cn/blog_migrate/b1af5563fd109b95b53c115633b446a9.png
4. 使用下令查看安装是否乐成,如下:
# 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
#
截图如下:
https://i-blog.csdnimg.cn/blog_migrate/84acb8196a179e9fa2070b76e180c2b8.png
5. 启动mysql服务,如下:
# 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: Starting MySQL Server...
Mar 04 16:59:31 VM-16-11-centos systemd: Started MySQL Server.
#
截图如下:
https://i-blog.csdnimg.cn/blog_migrate/7fb92085ea8cdfe9131d05bc012af13b.png
6. 查看数据库密码,和往常一样依然是随机密码,有日志可知本次密码为k*;2bsNU)&Oo,如下:
2024-03-04T08:59:22.920568Z 0 /usr/sbin/mysqld (mysqld 8.0.36) initializing of server in progress as process 22031
2024-03-04T08:59:22.949805Z 1 InnoDB initialization has started.
2024-03-04T08:59:23.861796Z 1 InnoDB initialization has ended.
2024-03-04T08:59:26.000382Z 6 A temporary password is generated for root@localhost: k*;2bsNU)&Oo
2024-03-04T08:59:31.115096Z 0 /usr/sbin/mysqld (mysqld 8.0.36) starting as process 22106
2024-03-04T08:59:31.131318Z 1 InnoDB initialization has started.
2024-03-04T08:59:31.335613Z 1 InnoDB initialization has ended.
2024-03-04T08:59:31.639123Z 0 CA certificate ca.pem is self signed.
2024-03-04T08:59:31.639170Z 0 Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2024-03-04T08:59:31.672087Z 0 /usr/sbin/mysqld: ready for connections. Version: '8.0.36'socket: '/var/lib/mysql/mysql.sock'port: 3306MySQL Community Server - GPL.
2024-03-04T08:59:31.672090Z 0 X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
截图如下:
https://i-blog.csdnimg.cn/blog_migrate/dd1c1b1404d9d54d7f84241f4de82aff.png
7.测试数据库链接,下令如下:
# 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>
截图如下:
https://i-blog.csdnimg.cn/blog_migrate/38c06253bca4ccd6be705f6d647e51a9.png

[*]基于以上,mysql安装完成!烨!✌
可以毗连以后,记得修改密码,下令:
ALTER USER USER() IDENTIFIED BY 'Root@123';
截图如下:
https://i-blog.csdnimg.cn/blog_migrate/daf700fb80ca0085446a8db77ddb7dfd.png
如果有修改配置文件的需求,使用以下下令修改配置文件,修改后重启生效:
# vim /etc/my.cnf
截图如下:
https://i-blog.csdnimg.cn/blog_migrate/4eba1fa3efb1c84beeb34dcfb1f05d77.png
问题集锦


[*]修改密码时报错: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,依然会报错。

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

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: 【mysql】 手把手教你安装mysql-8.0.36数据库