Centos7使用笔记:
1、设置永久挂载点
[root@centos7-test1 test1]# mount /dev/cdrom /mnt/cdrom
//挂载到/mnt/cdrom目录
[root@centos7-test1 test1]# blkid
//查看文件系统,查看UUID或者LABEL
[root@centos7-test1 test1]# cat /etc/fstab
root@centos7-test1 yum.repos.d]# cp ./repo_backup/CentOS-Sources.repo centos.repo
@第一部分:
[root@centos7-test1 test1]# mkdir /mnt/cdrom
[root@centos7-test1 test1]#
[root@centos7-test1 test1]#
[root@centos7-test1 test1]#
[root@centos7-test1 test1]#
[root@centos7-test1 test1]# mount /dev/cdrom /mnt/cdrom //挂载到/mnt/cdrom目录
`mount: /dev/sr0 写保护,将以只读方式挂载
[root@centos7-test1 test1]# ls /mnt/cdrom
CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7
EFI images Packages RPM-GPG-KEY-CentOS-Testing-7
EULA isolinux repodata TRANS.TBL`
[root@centos7-test1 test1]#
[root@centos7-test1 test1]#
[root@centos7-test1 test1]# blkid //查看文件系统,查看UUID或者LABEL
`/dev/sda1: UUID="7ddc3e98-8645-4402-8e8e-08cfb94dac51" TYPE="xfs"
/dev/sda2: UUID="edac12b5-b230-41c3-a612-fee5bd9bb898" TYPE="xfs"
/dev/sda3: UUID="9ab2ff8a-c542-468d-8ae6-11a1fd098267" TYPE="xfs"
/dev/sda5: UUID="562bc6b2-bfca-4d41-9418-d41d793f649f" TYPE="xfs"
/dev/sda6: UUID="07f24fbb-bafd-43cf-a26f-145ac65ffe00" TYPE="swap"
/dev/sda7: UUID="80ab4f52-d677-4cd6-80ee-360eb4f6b0a0" TYPE="xfs"
/dev/sda8: UUID="e55a2955-355f-4cfb-be92-d0351db404f9" TYPE="xfs"
/dev/sr0: UUID="2020-11-04-11-36-43-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos"`
@第二部分:
[root@centos7-test1 test1]# vi /etc/fstab
[root@centos7-test1 test1]#
[root@centos7-test1 test1]#
[root@centos7-test1 test1]#
[root@centos7-test1 test1]#
[root@centos7-test1 test1]#
[root@centos7-test1 test1]# cat /etc/fstab
`#
# /etc/fstab
# Created by anaconda on Sat Apr 1 10:32:06 2023
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=edac12b5-b230-41c3-a612-fee5bd9bb898 / xfs defaults 0 0
UUID=7ddc3e98-8645-4402-8e8e-08cfb94dac51 /boot xfs defaults 0 0
UUID=80ab4f52-d677-4cd6-80ee-360eb4f6b0a0 /home xfs defaults 0 0
UUID=9ab2ff8a-c542-468d-8ae6-11a1fd098267 /opt xfs defaults 0 0
UUID=562bc6b2-bfca-4d41-9418-d41d793f649f /tmp xfs defaults 0 0
UUID=e55a2955-355f-4cfb-be92-d0351db404f9 /var xfs defaults 0 0
UUID=07f24fbb-bafd-43cf-a26f-145ac65ffe00 swap swap defaults 0 0
UUID=2020-11-04-11-36-43-00 /mnt/cdrom iso9660 ro 0 0
`
添加UUID或者LABEL(标签) | 挂载点目录 | 指定文件系统(TYPE) | 挂在方式 | 使用dump工具备份功能 | 启动时扫描文件系统 |
---|---|---|---|---|---|
UUID/LABEL | path (路径有空格用`\040`表示) |
TYPE | ro(只读) defaults |
0:不用 1:使用 |
1:根文件系统 2:其他文件系统 0:无需文件扫描 |
UUID=2020-11-04-11-36-43-00 | /mnt/cdrom | iso9660 | ro | 0:不用 | 0:无需文件扫描 |
2、创建yum源
root@centos7-test1 test1]#
[root@centos7-test1 test1]#
[root@centos7-test1 test1]# cd /etc/yum.repos.d/
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]# ls
`CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo CentOS-x86_64-kernel.repo`
[root@centos7-test1 yum.repos.d]# mkdir repo_backup //创建备份.repo文件
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]# ls
`CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo repo_backup
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo CentOS-x86_64-kernel.repo`
[root@centos7-test1 yum.repos.d]# cp *.repo repo_backup/
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]# cp ./repo_backup/CentOS-Sources.repo centos.repo
//利用模板制作yum
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]# ls
centos.repo repo_backup
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]# vi centos.repo
[root@centos7-test1 yum.repos.d]#
root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]# cat centos.repo
`# CentOS-Sources.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[centos-cdrom]
name=centos-cdrom
baseurl=file:///mnt/cdrom //挂载的路径
gpgcheck=0 //0:不启用检查,1:启用检查
enabled=1
[root@centos7-test1 yum.repos.d]#
`
3、mysql的安装
[root@centos7-test1 yum.repos.d]# mkdir /opt/mysql
[root@centos7-test1 yum.repos.d]# rpm -qa | grep mysqld //查看是否有安装过的MySQL
[root@centos7-test1 mysql]# rpm -e --nodeps +安装包名 //删除MySQL
[root@centos7-test1 yum.repos.d]# wget -P /opt/mysql http://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
//下载到本地的指定目录中
[root@centos7-test1 mysql]# yum localinstall -y mysql80-community-release-el7-7.noarch.rpm
[root@centos7-test1 mysql]# yum install -y mysql-community-server
@第一部分:创建目录,下载mysql的rpm安装插件到本地指定目录
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]# mkdir /opt/mysql
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]# ls /opt
mysql rh
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]# rpm -qa | grep mysqld //查看是否有安装过的MySQL
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 yum.repos.d]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]# rpm -e --nodeps +安装包名 //删除MySQL
[root@centos7-test1 mysql]#
[root@centos7-test1 yum.repos.d]# wget -P /opt/mysql http://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
//下载到本地的指定目录中
`--2023-04-02 23:25:10-- http://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
正在解析主机 dev.mysql.com (dev.mysql.com)... 2402:4f00:4001:1a7::2e31, 2402:4f00:4001:192::2e31, 223.119.203.77
正在连接 dev.mysql.com (dev.mysql.com)|2402:4f00:4001:1a7::2e31|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 301 Moved Permanently
位置:https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm [跟随至新的 URL]
--2023-04-02 23:25:15-- https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
正在连接 dev.mysql.com (dev.mysql.com)|2402:4f00:4001:1a7::2e31|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Moved Temporarily
位置:https://repo.mysql.com//mysql80-community-release-el7-7.noarch.rpm [跟随至新的 URL]
--2023-04-02 23:25:16-- https://repo.mysql.com//mysql80-community-release-el7-7.noarch.rpm
正在解析主机 repo.mysql.com (repo.mysql.com)... 23.75.68.238
正在连接 repo.mysql.com (repo.mysql.com)|23.75.68.238|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:11196 (11K) [application/x-redhat-package-manager]
正在保存至: “/opt/mysql/mysql80-community-release-el7-7.noarch.rpm”
100%[==============================================================>] 11,196 --.-K/s 用时 0s
2023-04-02 23:25:29 (257 MB/s) - 已保存 “/opt/mysql/mysql80-community-release-el7-7.noarch.rpm” [11196/11196])`
[root@centos7-test1 yum.repos.d]# ls /opt/mysql
`mysql80-community-release-el7-7.noarch.rpm`
[root@centos7-test1 mysql]#
@第二部分:mysql的rpm插件安装
[root@centos7-test1 mysql]# yum localinstall -y mysql80-community-release-el7-7.noarch.rpm
`已加载插件:fastestmirror, langpacks
正在检查 mysql80-community-release-el7-7.noarch.rpm: mysql80-community-release-el7-7.noarch
mysql80-community-release-el7-7.noarch.rpm 将被安装
正在解决依赖关系
--> 正在检查事务
---> 软件包 mysql80-community-release.noarch.0.el7-7 将被 安装
--> 解决依赖关系完成
依赖关系解决
========================================================================================================
Package 架构 版本 源 大小
========================================================================================================
正在安装:
mysql80-community-release noarch el7-7 /mysql80-community-release-el7-7.noarch 10 k
事务概要
========================================================================================================
安装 1 软件包
总计:10 k
安装大小:10 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : mysql80-community-release-el7-7.noarch 1/1
验证中 : mysql80-community-release-el7-7.noarch 1/1
已安装:
mysql80-community-release.noarch 0:el7-7
完毕!`
[root@centos7-test1 mysql]# yum install -y mysql-community-server
`已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 mysql-community-server.x86_64.0.8.0.32-1.el7 将被 安装
--> 正在处理依赖关系 mysql-community-common(x86-64) = 8.0.32-1.el7,它被软件包 mysql-community-server-8.0.32-1.el7.x86_64 需要
--> 正在处理依赖关系 mysql-community-icu-data-files = 8.0.32-1.el7,它被软件包 mysql-community-server-8.0.32-1.el7.x86_64 需要
--> 正在处理依赖关系 mysql-community-client(x86-64) >= 8.0.11,它被软件包 mysql-community-server-8.0.32-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 mysql-community-client.x86_64.0.8.0.32-1.el7 将被 安装
--> 正在处理依赖关系 mysql-community-client-plugins = 8.0.32-1.el7,它被软件包 mysql-community-client-8.0.32-1.el7.x86_64 需要
--> 正在处理依赖关系 mysql-community-libs(x86-64) >= 8.0.11,它被软件包 mysql-community-client-8.0.32-1.el7.x86_64 需要
---> 软件包 mysql-community-common.x86_64.0.8.0.32-1.el7 将被 安装
---> 软件包 mysql-community-icu-data-files.x86_64.0.8.0.32-1.el7 将被 安装
--> 正在检查事务
---> 软件包 mysql-community-client-plugins.x86_64.0.8.0.32-1.el7 将被 安装
---> 软件包 mysql-community-libs.x86_64.0.8.0.32-1.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
========================================================================================================
Package 架构 版本 源 大小
========================================================================================================
正在安装:
mysql-community-server x86_64 8.0.32-1.el7 mysql80-community 64 M
为依赖而安装:
mysql-community-client x86_64 8.0.32-1.el7 mysql80-community 16 M
mysql-community-client-plugins x86_64 8.0.32-1.el7 mysql80-community 2.5 M
mysql-community-common x86_64 8.0.32-1.el7 mysql80-community 654 k
mysql-community-icu-data-files x86_64 8.0.32-1.el7 mysql80-community 2.1 M
mysql-community-libs x86_64 8.0.32-1.el7 mysql80-community 1.5 M
事务概要
========================================================================================================
安装 1 软件包 (+5 依赖软件包)
总下载量:87 M
安装大小:410 M
Downloading packages:
警告:/var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-client-plugins-8.0.32-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
mysql-community-client-plugins-8.0.32-1.el7.x86_64.rpm 的公钥尚未安装
(1/6): mysql-community-client-plugins-8.0.32-1.el7.x86_64.rpm | 2.5 MB 00:00:01
(2/6): mysql-community-common-8.0.32-1.el7.x86_64.rpm | 654 kB 00:00:00
(3/6): mysql-community-icu-data-files-8.0.32-1.el7.x86_64.rpm | 2.1 MB 00:00:00
(4/6): mysql-community-libs-8.0.32-1.el7.x86_64.rpm | 1.5 MB 00:00:00
(5/6): mysql-community-server-8.0.32-1.el7.x86_64.rpm | 64 MB 00:00:03
(6/6): mysql-community-client-8.0.32-1.el7.x86_64.rpm | 16 MB 00:00:05
--------------------------------------------------------------------------------------------------------
总计 16 MB/s | 87 MB 00:00:05
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022 检索密钥
导入 GPG key 0x3A79BD29:
用户ID : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
指纹 : 859b e8d7 c586 f538 430b 19c2 467b 942d 3a79 bd29
软件包 : mysql80-community-release-el7-7.noarch (@/mysql80-community-release-el7-7.noarch)
来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 检索密钥
导入 GPG key 0x5072E1F5:
用户ID : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
指纹 : a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
软件包 : mysql80-community-release-el7-7.noarch (@/mysql80-community-release-el7-7.noarch)
来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : mysql-community-client-plugins-8.0.32-1.el7.x86_64 1/6
正在安装 : mysql-community-common-8.0.32-1.el7.x86_64 2/6
正在安装 : mysql-community-libs-8.0.32-1.el7.x86_64 3/6
正在安装 : mysql-community-client-8.0.32-1.el7.x86_64 4/6
正在安装 : mysql-community-icu-data-files-8.0.32-1.el7.x86_64 5/6
正在安装 : mysql-community-server-8.0.32-1.el7.x86_64 6/6
验证中 : mysql-community-libs-8.0.32-1.el7.x86_64 1/6
验证中 : mysql-community-icu-data-files-8.0.32-1.el7.x86_64 2/6
验证中 : mysql-community-client-8.0.32-1.el7.x86_64 3/6
验证中 : mysql-community-common-8.0.32-1.el7.x86_64 4/6
验证中 : mysql-community-client-plugins-8.0.32-1.el7.x86_64 5/6
验证中 : mysql-community-server-8.0.32-1.el7.x86_64 6/6
已安装:
mysql-community-server.x86_64 0:8.0.32-1.el7
作为依赖被安装:
mysql-community-client.x86_64 0:8.0.32-1.el7 mysql-community-client-plugins.x86_64 0:8.0.32-1.el7
mysql-community-common.x86_64 0:8.0.32-1.el7 mysql-community-icu-data-files.x86_64 0:8.0.32-1.el7
mysql-community-libs.x86_64 0:8.0.32-1.el7
完毕!`
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
4、MySQL安装的目录结构
mysql目录 | 说明 |
---|---|
/var/lib/mysql | mysql数据文件存放路径 |
/etc/my.cnf | mysql配置文件路径 |
/usr/lib64/mysql | mysql库文件路径 |
/usr/bin/mysql* | mysql二进制可执行文件路径 |
/etc/rc.d/init.d/mysqld | mysql服务管理脚本地址 |
/var/log/mysqld.log | mysql日志文件路径 |
5、mysql注册初始化、授予所有者,以及权限
[root@centos7-test1 mysql]# chown -R mysql:mysql /var/lib/mysql/
//将当前前目录下的所有文件与子目录的拥有者皆设为 mysql,群体的使用者 mysql
[root@centos7-test1 mysql]# mysqld --initialize
//注册初始化数据库
[root@centos7-test1 mysql]# ps -aux | grep mysql
//查看进程状
[root@centos7-test1 mysql]# tail -n 20 /var/log/mysqld.log
//tail查看日志信息排
root@centos7-test1 mysql]# setenforce 0
[root@centos7-test1 mysql]# chmod 777 /var/lib/mysql
@第一部分:设置文件所有者和文件关联组、MySQL注册初始化
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]# chown -R mysql:mysql /var/lib/mysql/
//将当前前目录下的所有文件与子目录的拥有者皆设为 mysql,群体的使用者 mysql
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]# mysqld --initialize
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
@赋予最高权限,启动MySQL
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]# chmod 777 /var/lib/mysql
//给/var/lib/mysql目录下的所有文件设置最高权限:注权限不足mysql不能正常打开
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]# systemctl start mysqld.service
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]# systemctl status mysqld.service
`● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since 一 2023-04-03 01:19:03 CST; 15s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 18651 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 18683 (mysqld)
Status: "Server is operational"
Tasks: 39
CGroup: /system.slice/mysqld.service
└─18683 /usr/sbin/mysqld
4月 03 01:19:02 centos7-test1 systemd[1]: Starting MySQL Server...
4月 03 01:19:03 centos7-test1 systemd[1]: Started MySQL Server.`
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
@第二部分:启动MySQL失败问题:
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]# service mysqld status
`Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 一 2023-04-03 00:35:57 CST; 16min ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 16479 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=1/FAILURE)
Process: 16447 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 16479 (code=exited, status=1/FAILURE)
Status: "Server shutdown complete"
Error: 13 (权限不够)
4月 03 00:35:56 centos7-test1 systemd[1]: Starting MySQL Server...
4月 03 00:35:57 centos7-test1 systemd[1]: mysqld.service: main process exited, code=...RE
4月 03 00:35:57 centos7-test1 systemd[1]: Failed to start MySQL Server.
4月 03 00:35:57 centos7-test1 systemd[1]: Unit mysqld.service entered failed state.
4月 03 00:35:57 centos7-test1 systemd[1]: mysqld.service failed.
Hint: Some lines were ellipsized, use -l to show in full.`
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]# service mysqld status
`Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 一 2023-04-03 00:35:57 CST; 17min ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 16479 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=1/FAILURE)
Process: 16447 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 16479 (code=exited, status=1/FAILURE)
Status: "Server shutdown complete"
Error: 13 (权限不够)
4月 03 00:35:56 centos7-test1 systemd[1]: Starting MySQL Server...
4月 03 00:35:57 centos7-test1 systemd[1]: mysqld.service: main process exited, code=...RE
4月 03 00:35:57 centos7-test1 systemd[1]: Failed to start MySQL Server.
4月 03 00:35:57 centos7-test1 systemd[1]: Unit mysqld.service entered failed state.
4月 03 00:35:57 centos7-test1 systemd[1]: mysqld.service failed.
Hint: Some lines were ellipsized, use -l to show in full.`
[root@centos7-test1 mysql]# ps -aux | grep mysql //查看进程状态
`root 17546 0.0 0.0 112824 980 pts/0 S+ 00:53 0:00 grep --color=auto mysql`
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]# tail -n 20 /var/log/mysqld.log //tail查看日志信息排查
`2023-04-02T16:34:44.786480Z 0 [Warning] [MY-010075] [Server] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 4684a7a0-d174-11ed-b847-000c29161a77.
mysqld: File '/var/lib/mysql/auto.cnf' not found (OS errno 13 - Permission denied)
2023-04-02T16:34:44.786512Z 0 [ERROR] [MY-010183] [Server] Failed to create file(file: '/var/lib/mysql/auto.cnf', errno 13)
2023-04-02T16:34:44.786517Z 0 [ERROR] [MY-010076] [Server] Initialization of the server's UUID failed because it could not be read from the auto.cnf file. If this is a new server, the initialization failed because it was not possible to generate a new UUID.
2023-04-02T16:34:44.786592Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-04-02T16:34:44.787262Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.32) MySQL Community Server - GPL.
2023-04-02T16:35:57.462273Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.32) starting as process 16479
2023-04-02T16:35:57.469868Z 0 [Warning] [MY-010075] [Server] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 71d7431f-d174-11ed-be55-000c29161a77.
mysqld: File '/var/lib/mysql/auto.cnf' not found (OS errno 13 - Permission denied)
2023-04-02T16:35:57.469928Z 0 [ERROR] [MY-010183] [Server] Failed to create file(file: '/var/lib/mysql/auto.cnf', errno 13)
2023-04-02T16:35:57.469934Z 0 [ERROR] [MY-010076] [Server] Initialization of the server's UUID failed because it could not be read from the auto.cnf file. If this is a new server, the initialization failed because it was not possible to generate a new UUID.
2023-04-02T16:35:57.469974Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-04-02T16:35:57.470371Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.32) MySQL Community Server - GPL.
2023-04-02T17:19:02.921980Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.32) starting as process 18683
2023-04-02T17:19:02.932071Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-04-02T17:19:03.139527Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-04-02T17:19:03.384473Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-04-02T17:19:03.384514Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-04-02T17:19:03.400634Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2023-04-02T17:19:03.400714Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.32' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server - GPL.`
[root@centos7-test1 mysql]#
@第三部分:经排查发现由于mysql目录权限不足导致,设置最高权限重启成功:
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
root@centos7-test1 mysql]# setenforce 0
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]# chown -R mysql:mysql /var/lib/mysql
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]# chmod 777 /var/lib/mysql
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]# systemctl start mysqld.service
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]# systemctl status mysqld.service
`● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since 一 2023-04-03 01:19:03 CST; 15s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 18651 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 18683 (mysqld)
Status: "Server is operational"
Tasks: 39
CGroup: /system.slice/mysqld.service
└─18683 /usr/sbin/mysqld
4月 03 01:19:02 centos7-test1 systemd[1]: Starting MySQL Server...
4月 03 01:19:03 centos7-test1 systemd[1]: Started MySQL Server.`
[root@centos7-test1 mysql]#
[root@centos7-test1 mysql]#