/usr/libexec/mysqld: Can't change dir to '/xxx' (Errcode: 13) 解决

本文介绍了如何解决MySQL启动过程中出现的警告与错误信息,包括权限设置问题和SELINUX权限限制等问题,并提供了解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

当看到错误日志里面如下记录:

mysqld started

[Warning] Can't create test file xxx.lower-test
[Warning] Can't create test file xxx.lower-test
/usr/libexec/mysqld: Can't change dir to '/xxx' (Errcode: 13)

[ERROR] Aborting

首先检查数据目录和日志目录的权限和所属用户,如果权限和所属用户都没问题,那应该是SELINUX的权限限制了。

对你的数据目录和日志目录执行如下命令:

chcon -R system_u:object_r:mysqld_db_t:s0 /media/sda3/mysql/

一切问题迎刃而解

实在不行重启电脑!!!

[root@localhost bin]# cat /etc/my.cnf [mysqld] bind-address=0.0.0.0 port=3306 user=mysql basedir=/usr/local/mysql datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock log-error=/data/mysql/mysql.err pid-file=/data/mysql/mysql.pid #character config character_set_server=utf8mb4 symbolic-links=0 explicit_defaults_for_timestamp=true default_authentication_plugin = mysql_native_password symbolic-links=0 plugin_load_add='component_reference_cache.so' [root@localhost bin]# journalctl -xe -u mysqld --no-pager 7月 14 17:24:42 localhost.localdomain systemd[1]: Starting MySQL 8.0 database server... ░░ Subject: mysqld.service 单元已开始启动 ░░ Defined-By: systemd ░░ Support: https://wiki.rockylinux.org/rocky/support ░░ ░░ mysqld.service 单元已开始启动。 7月 14 17:24:42 localhost.localdomain mysqld[40957]: 2025-07-14T09:24:42.446697Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release. 7月 14 17:24:42 localhost.localdomain mysqld[40957]: 2025-07-14T09:24:42.446841Z 0 [Warning] [MY-010091] [Server] Can't create test file /data/mysql/mysqld_tmp_file_case_insensitive_test.lower-test 7月 14 17:24:42 localhost.localdomain mysqld[40957]: 2025-07-14T09:24:42.446899Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead. 7月 14 17:24:42 localhost.localdomain mysqld[40957]: 2025-07-14T09:24:42.446924Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.41) starting as process 40957 7月 14 17:24:42 localhost.localdomain mysqld[40957]: 2025-07-14T09:24:42.449879Z 0 [Warning] [MY-010091] [Server] Can't create test file /data/mysql/mysqld_tmp_file_case_insensitive_test.lower-test 7月 14 17:24:42 localhost.localdomain mysqld[40957]: 2025-07-14T09:24:42.449886Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /data/mysql/ is case insensitive 7月 14 17:24:42 localhost.localdomain mysqld[40957]: 2025-07-14T09:24:42.450361Z 0 [ERROR] [MY-010187] [Server] Could not open file '/data/mysql/mysql.err' for error logging: Permission denied 7月 14 17:24:42 localhost.localdomain mysqld[40957]: 2025-07-14T09:24:42.450447Z 0 [ERROR] [MY-010119] [Server] Aborting 7月 14 17:24:42 localhost.localdomain mysqld[40957]: 2025-07-14T09:24:42.450568Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.41) Source distribution. 7月 14 17:24:42 localhost.localdomain systemd[1]: mysqld.service: Main process exited, code=exited, status=1/FAILURE ░░ Subject: Unit process exited ░░ Defined-By: systemd ░░ Support: https://wiki.rockylinux.org/rocky/support ░░ ░░ An ExecStart= process belonging to unit mysqld.service has exited. ░░ ░░ The process' exit code is 'exited' and its exit status is 1. 7月 14 17:25:43 localhost.localdomain systemd[1]: mysqld.service: Control process exited, code=exited, status=3/NOTIMPLEMENTED ░░ Subject: Unit process exited ░░ Defined-By: systemd ░░ Support: https://wiki.rockylinux.org/rocky/support ░░ ░░ An ExecStopPost= process belonging to unit mysqld.service has exited. ░░ ░░ The process' exit code is 'exited' and its exit status is 3. 7月 14 17:25:43 localhost.localdomain systemd[1]: mysqld.service: Failed with result 'exit-code'. ░░ Subject: Unit failed ░░ Defined-By: systemd ░░ Support: https://wiki.rockylinux.org/rocky/support ░░ ░░ The unit mysqld.service has entered the 'failed' state with result 'exit-code'. 7月 14 17:25:43 localhost.localdomain systemd[1]: Failed to start MySQL 8.0 database server. ░░ Subject: mysqld.service 单元已失败 ░░ Defined-By: systemd ░░ Support: https://wiki.rockylinux.org/rocky/support ░░ ░░ mysqld.service 单元已失败。 ░░ ░░ 结果为“failed”。 7月 14 17:30:58 localhost.localdomain systemd[1]: Starting MySQL 8.0 database server... ░░ Subject: mysqld.service 单元已开始启动 ░░ Defined-By: systemd ░░ Support: https://wiki.rockylinux.org/rocky/support ░░ ░░ mysqld.service 单元已开始启动。 7月 14 17:30:59 localhost.localdomain mysqld[41251]: 2025-07-14T09:30:59.223243Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release. 7月 14 17:30:59 localhost.localdomain mysqld[41251]: 2025-07-14T09:30:59.223383Z 0 [Warning] [MY-010091] [Server] Can't create test file /data/mysql/mysqld_tmp_file_case_insensitive_test.lower-test 7月 14 17:30:59 localhost.localdomain mysqld[41251]: 2025-07-14T09:30:59.223443Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead. 7月 14 17:30:59 localhost.localdomain mysqld[41251]: 2025-07-14T09:30:59.223469Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.41) starting as process 41251 7月 14 17:30:59 localhost.localdomain mysqld[41251]: 2025-07-14T09:30:59.226383Z 0 [Warning] [MY-010091] [Server] Can't create test file /data/mysql/mysqld_tmp_file_case_insensitive_test.lower-test 7月 14 17:30:59 localhost.localdomain mysqld[41251]: 2025-07-14T09:30:59.226390Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /data/mysql/ is case insensitive 7月 14 17:30:59 localhost.localdomain mysqld[41251]: 2025-07-14T09:30:59.226871Z 0 [ERROR] [MY-010187] [Server] Could not open file '/data/mysql/mysql.err' for error logging: Permission denied 7月 14 17:30:59 localhost.localdomain mysqld[41251]: 2025-07-14T09:30:59.226952Z 0 [ERROR] [MY-010119] [Server] Aborting 7月 14 17:30:59 localhost.localdomain mysqld[41251]: 2025-07-14T09:30:59.227071Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.41) Source distribution. 7月 14 17:30:59 localhost.localdomain systemd[1]: mysqld.service: Main process exited, code=exited, status=1/FAILURE ░░ Subject: Unit process exited ░░ Defined-By: systemd ░░ Support: https://wiki.rockylinux.org/rocky/support ░░ ░░ An ExecStart= process belonging to unit mysqld.service has exited. ░░ ░░ The process' exit code is 'exited' and its exit status is 1. 7月 14 17:32:00 localhost.localdomain systemd[1]: mysqld.service: Control process exited, code=exited, status=3/NOTIMPLEMENTED ░░ Subject: Unit process exited ░░ Defined-By: systemd ░░ Support: https://wiki.rockylinux.org/rocky/support ░░ ░░ An ExecStopPost= process belonging to unit mysqld.service has exited. ░░ ░░ The process' exit code is 'exited' and its exit status is 3. 7月 14 17:32:00 localhost.localdomain systemd[1]: mysqld.service: Failed with result 'exit-code'. ░░ Subject: Unit failed ░░ Defined-By: systemd ░░ Support: https://wiki.rockylinux.org/rocky/support ░░ ░░ The unit mysqld.service has entered the 'failed' state with result 'exit-code'. 7月 14 17:32:00 localhost.localdomain systemd[1]: Failed to start MySQL 8.0 database server. ░░ Subject: mysqld.service 单元已失败 ░░ Defined-By: systemd ░░ Support: https://wiki.rockylinux.org/rocky/support ░░ ░░ mysqld.service 单元已失败。 ░░ ░░ 结果为“failed”。 7月 14 17:42:23 localhost.localdomain systemd[1]: Starting MySQL 8.0 database server... ░░ Subject: mysqld.service 单元已开始启动 ░░ Defined-By: systemd ░░ Support: https://wiki.rockylinux.org/rocky/support ░░ ░░ mysqld.service 单元已开始启动。 7月 14 17:42:23 localhost.localdomain mysql-prepare-db-dir[41483]: Initializing MySQL database 7月 14 17:42:29 localhost.localdomain mysqld[41560]: 2025-07-14T09:42:29.622474Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release. 7月 14 17:42:29 localhost.localdomain mysqld[41560]: 2025-07-14T09:42:29.622487Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release. 7月 14 17:42:29 localhost.localdomain mysqld[41560]: 2025-07-14T09:42:29.624267Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead. 7月 14 17:42:29 localhost.localdomain mysqld[41560]: 2025-07-14T09:42:29.624296Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.41) starting as process 41560 7月 14 17:42:29 localhost.localdomain mysqld[41560]: 2025-07-14T09:42:29.626446Z 0 [ERROR] [MY-010187] [Server] Could not open file '/data/mysql/mysql.err' for error logging: Permission denied 7月 14 17:42:29 localhost.localdomain mysqld[41560]: 2025-07-14T09:42:29.626524Z 0 [ERROR] [MY-010119] [Server] Aborting 7月 14 17:42:29 localhost.localdomain mysqld[41560]: 2025-07-14T09:42:29.626659Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.41) Source distribution. 7月 14 17:42:29 localhost.localdomain systemd[1]: mysqld.service: Main process exited, code=exited, status=1/FAILURE ░░ Subject: Unit process exited ░░ Defined-By: systemd ░░ Support: https://wiki.rockylinux.org/rocky/support ░░ ░░ An ExecStart= process belonging to unit mysqld.service has exited. ░░ ░░ The process' exit code is 'exited' and its exit status is 1. 7月 14 17:43:30 localhost.localdomain systemd[1]: mysqld.service: Control process exited, code=exited, status=3/NOTIMPLEMENTED ░░ Subject: Unit process exited ░░ Defined-By: systemd ░░ Support: https://wiki.rockylinux.org/rocky/support ░░ ░░ An ExecStopPost= process belonging to unit mysqld.service has exited. ░░ ░░ The process' exit code is 'exited' and its exit status is 3. 7月 14 17:43:30 localhost.localdomain systemd[1]: mysqld.service: Failed with result 'exit-code'. ░░ Subject: Unit failed ░░ Defined-By: systemd ░░ Support: https://wiki.rockylinux.org/rocky/support ░░ ░░ The unit mysqld.service has entered the 'failed' state with result 'exit-code'. 7月 14 17:43:30 localhost.localdomain systemd[1]: Failed to start MySQL 8.0 database server. ░░ Subject: mysqld.service 单元已失败 ░░ Defined-By: systemd ░░ Support: https://wiki.rockylinux.org/rocky/support ░░ ░░ mysqld.service 单元已失败。 ░░ ░░ 结果为“failed”。 7月 14 17:43:30 localhost.localdomain systemd[1]: mysqld.service: Consumed 2.187s CPU time. ░░ Subject: Resources consumed by unit runtime ░░ Defined-By: systemd ░░ Support: https://wiki.rockylinux.org/rocky/support ░░ ░░ The unit mysqld.service completed and consumed the indicated resources. [root@localhost bin]# ls /var/lib/mysql/*.err ls: 无法访问 '/var/lib/mysql/*.err': 没有那个文件或目录 [root@localhost bin]# tail -n 50 /var/lib/mysql/localhost.err tail: 无法打开'/var/lib/mysql/localhost.err' 读取数据: 没有那个文件或目录 [root@localhost bin]#
最新发布
07-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值