1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【MySQL】アクセス権限エラーで突如MySQLが起動できなくなった件

Posted at

Amazon Linux2で「yum update」すると、突如MySQLが起動しなくなりました。

次のコマンドを実行。

$ systemctl start mysqld.service

次のエラーが発生。

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

「systemctl status mysqld.service」や「journalctl -xe」を見てと書いてあるが見ても原因はわからず。。。
下記を実行してMySQLのログを確認。

$ less /var/log/mysqld.log
出力ログ
2020-08-03T03:41:05.785105Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-08-03T03:41:05.787080Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.31) starting as process 20768 ...
2020-08-03T03:41:05.791536Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-08-03T03:41:05.791556Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-08-03T03:41:05.791560Z 0 [Note] InnoDB: Uses event mutexes
2020-08-03T03:41:05.791564Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-08-03T03:41:05.791568Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-08-03T03:41:05.791573Z 0 [Note] InnoDB: Using Linux native AIO
2020-08-03T03:41:05.791793Z 0 [Note] InnoDB: Number of pools: 1
2020-08-03T03:41:05.791873Z 0 [Note] InnoDB: Using CPU crc32 instructions
mysqld: Can't create/write to file '/tmp/ibbHa1X6' (Errcode: 13 - Permission denied)
2020-08-03T03:41:05.791916Z 0 [ERROR] InnoDB: Unable to create temporary file; errno: 13
2020-08-03T03:41:05.791922Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-08-03T03:41:05.791927Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-08-03T03:41:05.791930Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-08-03T03:41:05.791933Z 0 [ERROR] Failed to initialize builtin plugins.
2020-08-03T03:41:05.791936Z 0 [ERROR] Aborting

2020-08-03T03:41:05.791970Z 0 [Note] Binlog end
2020-08-03T03:41:05.792017Z 0 [Note] Shutting down plugin 'CSV'
2020-08-03T03:41:05.792245Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

「mysqld: Can't create/write to file '/tmp/ibbHa1X6' (Errcode: 13 - Permission denied)」
ここが原因でした。
翻訳すると、「アクセスが拒否されて、「/tmp/ibbHa1X6」にファイルを作成、書き込みができません。」と書かれています。
「/tmp」のアクセス権限を確認すると、所有者以外書き込みができないようになっていました。

drwxr-xr-x   8 root root  253 Aug  3 03:58 tmp

次のコマンドで権限を変更。

$ chmod 777 /tmp
drwxrwxrwx   8 root root  253 Aug  3 03:58 tmp

これで、無事MySQLにアクセスできるようになりました。
このエラーが発生した原因はわからないままです。(yum updateで「/tmp」の権限が変わったのか、「/tmp」を使うようになったのか・・・?)

今回は簡単な修正でしたが、MySQLのステータスやログを確認する機会が少なく、割と時間がかかったので記事に残しておきます。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?