我尝试开始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.
和须藤:
[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
以 root 身份运行。正如错误消息实际上告诉您的那样,这就是当您使用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
。