始めようmysql仕える人AlmaLinuxでは:
[asigor@89 etc]$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
起動できないと思います。mysqldまたはこれを行うとき:
[asigor@89 etc]$ mysqld
2023-05-10T14:47:28.044565Z 0 [Warning] [MY-010091] [Server] Can't create test file /var/lib/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
2023-05-10T14:47:28.044617Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2023-05-10T14:47:28.044643Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.30) starting as process 279360
2023-05-10T14:47:28.046672Z 0 [Warning] [MY-010091] [Server] Can't create test file /var/lib/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
2023-05-10T14:47:28.046683Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2023-05-10T14:47:28.049143Z 0 [ERROR] [MY-010187] [Server] Could not open file '/var/log/mysql/mysqld.log' for error logging: Permission denied
2023-05-10T14:47:28.049221Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-05-10T14:47:28.049356Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.30) Source distribution.
そしてSudo:
[asigor@89 etc]$ sudo mysqld start
2023-05-10T15:07:35.437541Z 0 [Warning] [MY-010918] [Server] 'default_authentica tion_plugin' is deprecated and will be removed in a future release. Please use a uthentication_policy instead.
2023-05-10T15:07:35.437570Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.30) starting as process 279878
2023-05-10T15:07:35.439010Z 0 [ERROR] [MY-010123] [Server] Fatal error: Please r ead "Security" section of the manual to find out how to run mysqld as root!
2023-05-10T15:07:35.439051Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-05-10T15:07:35.439143Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.30) Source distribution.
どのようなヒント/コツがありますか?
修正する
[asigor@89 ~]$ sudo systemctl start mysql
[asigor@89 ~]$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib
[asigor@89 ~]$ journalctl -u mysql.service
Hint: You are currently not seeing messages from other users and the system.
Users in the 'systemd-journal' group can see all messages. Pass -q to
turn off this notice.
No journal files were opened due to insufficient permissions.
アップデート2
@"Marcus Mueller"は以下にコメントしました。
$ sudo systemctl start mysql
$ sudo journalctl -u mysql.service
-- Logs begin at Thu 2023-05-11 01:00:01 UTC, end at Fri 2023-05-12 07:43:08 UT>
May 12 07:42:58 89.162.205.92.host.secureserver.net systemd[1]: Started MySQL S>
May 12 07:42:58 89.162.205.92.host.secureserver.net systemd[1]: mysql.service: >
May 12 07:42:58 89.162.205.92.host.secureserver.net systemd[1]: mysql.service: >
lines 1-4/4 (END)
-- Logs begin at Thu 2023-05-11 01:00:01 UTC, end at Fri 2023-05-12 07:43:08 UTC. --
May 12 07:42:58 89.162.205.92.host.secureserver.net systemd[1]: Started MySQL Server.
May 12 07:42:58 89.162.205.92.host.secureserver.net systemd[1]: mysql.service: Main process exited, code=exited,>
May 12 07:42:58 89.162.205.92.host.secureserver.net systemd[1]: mysql.service: Failed with result 'exit-code'.
間違い:「終了コード」のため失敗しました。。
アップデート3
$ sudo journalctl -u mysql.service > journal.txt
ファイルからコピーされたログコンテンツ:
-- Logs begin at Thu 2023-05-11 01:00:01 UTC, end at Fri 2023-05-12 10:13:00 UTC. --
May 12 07:42:58 89.162.205.92.host.secureserver.net systemd[1]: Started MySQL Server.
May 12 07:42:58 89.162.205.92.host.secureserver.net systemd[1]: mysql.service: Main process exited, code=exited, status=203/EXEC
May 12 07:42:58 89.162.205.92.host.secureserver.net systemd[1]: mysql.service: Failed with result 'exit-code'.
アップデート4
$ sudo pgrep mysqld
$ sudo journalctl -u pgrep.service
-- Logs begin at Thu 2023-05-11 01:00:01 UTC, end at Fri 2023-05-12 11:22:12 UT>
-- No entries --
アップデート5
どういうわけかmysqlを起動しようとして失敗するようです。
systemctl mysqld.service start
ステータスを見る:
systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/etc/systemd/system/mysqld.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2023-05-16 10:49:21 UTC; 37s ago
Process: 567142 ExecStart=/usr/bin/mysqld --defaults-file=/etc/mysql/my.cnf --datadir=/var/lib/mysql --socket=/var/run/mysqld/mysqld.>
Main PID: 567142 (code=exited, status=203/EXEC)
答え1
mysqld
ルートとして実行しないでください。エラーメッセージで実際にわかるようにsudo
。mysqld
ユーザーとして手動で実行すると、asigor
/var/lib/mysql/ にコンテンツは生成されません。メッセージには次の内容も含まれています。
テストファイル/var/lib/mysql/mysqld_tmp_file_case_insensitive_test.lower-testを生成できません。
解決策は簡単です。 mysqldを手動で起動しないでくださいsudo systemctl start mysql
。journalctl -u mysql.service