MySQL启动报错(Can‘t change dir to ‘/usr/local/mysql/data/‘ (Errcode: 2 - No such file or director)

报错场景

在启动服务时,

systemctl restart mysql_4405
Job for mysql_4405.service failed because the control process exited with error code. See "systemctl status mysql_4405.service" and "journalctl -xe" for details.

详细日志
journalctl -xe
-- 
-- Unit mysql_4405.service has begun starting up.
Oct 25 01:59:00 sudada mysqld[18277]: mysqld: [Warning] World-writable config file '/data/mysql/4405/my.cnf.4405' is ignored.
Oct 25 01:59:00 sudada mysqld[18277]: mysqld: Can't change dir to '/usr/local/mysql/data/' (Errcode: 2 - No such file or director
Oct 25 01:59:00 sudada mysqld[18277]: 2023-10-25T01:59:00.812489Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated
Oct 25 01:59:00 sudada mysqld[18277]: 2023-10-25T01:59:00.812641Z 0 [Note] --secure-file-priv is set to NULL. Operations related 
Oct 25 01:59:00 sudada mysqld[18277]: 2023-10-25T01:59:00.812672Z 0 [Note] /data/mysql/4405/base/bin/mysqld (mysqld 5.7.43) start
Oct 25 01:59:00 sudada mysqld[18277]: 2023-10-25T01:59:00.812701Z 0 [ERROR] Can't find error-message file '/usr/local/mysql/share
Oct 25 01:59:00 sudada mysqld[18277]: 2023-10-25T01:59:00.813206Z 0 [Warning] Can't create test file /usr/local/mysql/data/sudada
Oct 25 01:59:00 sudada mysqld[18277]: 2023-10-25T01:59:00.813211Z 0 [Warning] Can't create test file /usr/local/mysql/data/sudada
Oct 25 01:59:00 sudada mysqld[18277]: 2023-10-25T01:59:00.813266Z 0 [ERROR] failed to set datadir to /usr/local/mysql/data/
Oct 25 01:59:00 sudada mysqld[18277]: 2023-10-25T01:59:00.813272Z 0 [ERROR] Aborting
Oct 25 01:59:00 sudada mysqld[18277]: 2023-10-25T01:59:00.813300Z 0 [Note] Binlog end
Oct 25 01:59:00 sudada systemd[1]: mysql_4405.service: control process exited, code=exited status=1
Oct 25 01:59:00 sudada mysqld[18277]: Initialization of mysqld failed: 0
Oct 25 01:59:00 sudada mysqld[18277]: 2023-10-25T01:59:00.814179Z 0 [Note]
Oct 25 01:59:00 sudada systemd[1]: Failed to start MySQL Server.
-- Subject: Unit mysql_4405.service has failed

因为错误日志没有输出(下面只是关闭时候的日志,没有启动日志)

2023-10-25T01:58:59.009620-00:00 0 [Note] Shutting down plugin 'MyISAM'
2023-10-25T01:58:59.009648-00:00 0 [Note] Shutting down plugin 'MRG_MYISAM'
2023-10-25T01:58:59.009664-00:00 0 [Note] Shutting down plugin 'MEMORY'
2023-10-25T01:58:59.009671-00:00 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2023-10-25T01:58:59.009702-00:00 0 [Note] Shutting down plugin 'sha256_password'
2023-10-25T01:58:59.009709-00:00 0 [Note] Shutting down plugin 'mysql_native_password'
2023-10-25T01:58:59.009997-00:00 0 [Note] Shutting down plugin 'binlog'
2023-10-25T01:58:59.010825-00:00 0 [Note] /data/mysql/4405/base/bin/mysqld: Shutdown complete

问题要点

  • /usr/local/mysql/data/目录不是 服务的实际目录(实际目录是/data/mysql/4405/data)
  • 且没有/usr/local/mysql/data/目录的存在

解决办法

mysqld: [Warning] World-writable config file ‘/data/mysql/4405/my.cnf.4405’ is ignored.
上面的启动日志 “World-writable“ 配置文件的权限太大了。

解决办法,把777改成了644就可以启动了
chmod 644 /data/mysql/4405/my.cnf.4405

好奇怪的报错,结论是配置文件权限不能是777。
完结撒花

你可能感兴趣的:(mysql,android,数据库)