当我尝试启动 mysqld 时,出现此错误。有什么想法可以解决此问题吗?我应该以 sudo 身份运行它吗?根据互联网上的一些教程,他们不需要使用 sudo。我在 Lubuntu 22.04 上使用 MYSQL 社区版
(base) alfredo@alfredo-hpelitebook725g4:~$ mysqld
2022-05-15T19:32:38.246287Z 0 [Warning] [MY-010091] [Server] Can't create test file /var/lib/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
2022-05-15T19:32:38.246379Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.28) starting as process 10661
2022-05-15T19:32:38.249975Z 0 [Warning] [MY-010091] [Server] Can't create test file /var/lib/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
2022-05-15T19:32:38.249987Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2022-05-15T19:32:38.250023Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to '/var/lib/mysql/' (OS errno: 13 - Permission denied)
2022-05-15T19:32:38.250157Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-05-15T19:32:38.253779Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.28) MySQL Community Server - GPL.
(base) alfredo@alfredo-hpelitebook725g4:~$
答案1
mysqld 不适合由普通用户运行。通过其 systemd 单元启动它。
sudo systemctl enable mysql
sudo systemctl start mysql