在 CentOS7 上启动 mysql 失败

时间:2021-05-29 03:00:34

标签: mysql

我在我的服务器上安装了 mysql。但是启动失败。

此处显示错误:

systemctl status mysqld.service 信息:

[root@localhost run]# systemctl status mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: failed (Result: start-limit) since Sat 2021-05-29 10:47:55 CST; 35s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 256566 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=217/USER)

May 29 10:47:55 localhost.localdomain systemd[1]: Failed to start MySQL Server.
May 29 10:47:55 localhost.localdomain systemd[1]: Unit mysqld.service entered failed state.
May 29 10:47:55 localhost.localdomain systemd[1]: mysqld.service failed.
May 29 10:47:55 localhost.localdomain systemd[1]: mysqld.service holdoff time over, sche...t.
May 29 10:47:55 localhost.localdomain systemd[1]: Stopped MySQL Server.
May 29 10:47:55 localhost.localdomain systemd[1]: start request repeated too quickly for...ce
May 29 10:47:55 localhost.localdomain systemd[1]: Failed to start MySQL Server.
May 29 10:47:55 localhost.localdomain systemd[1]: Unit mysqld.service entered failed state.
May 29 10:47:55 localhost.localdomain systemd[1]: mysqld.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

journalctl -xe信息:

May 29 10:48:00 localhost.localdomain postfix/master[21438]: warning: process /usr/libexec/postfix/pickup pid 257074 exit status 127
May 29 10:48:00 localhost.localdomain postfix/master[21438]: warning: /usr/libexec/postfix/pickup: bad command startup -- throttling
May 29 10:49:00 localhost.localdomain postfix/master[21438]: warning: process /usr/libexec/postfix/pickup pid 263057 exit status 127
May 29 10:49:00 localhost.localdomain postfix/master[21438]: warning: /usr/libexec/postfix/pickup: bad command startup -- throttling
May 29 10:50:00 localhost.localdomain postfix/master[21438]: warning: process /usr/libexec/postfix/pickup pid 269083 exit status 127
May 29 10:50:00 localhost.localdomain postfix/master[21438]: warning: /usr/libexec/postfix/pickup: bad command startup -- throttling
May 29 10:50:01 localhost.localdomain systemd[1]: Started Session 2986 of user root.
-- Subject: Unit session-2986.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit session-2986.scope has finished starting up.
-- 
-- The start-up result is done.

我尝试运行 chown -R mysql:mysql /var/lib/mysql,它显示如下:

chown: invalid user: ‘mysql:mysql’

如何启动mysql?

1 个答案:

答案 0 :(得分:0)

您可以通过几个步骤解决此问题

  1. 执行此命令检查mysql用户是否存在:cat /etc/passwd | grep mysql
  2. 验证此文件中是否有 mysql。它应该类似于:mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/false
  3. 如果 mysql 用户不存在,请像这样创建该用户:useradd -d /var/lib/mysql mysql
  4. 如果存在 mysql 用户,则确保 /etc/passwd 文件中的 mysql 用户主路径实际存在并由 mysql 用户拥有(在上述情况下,我提到 /var/lib/mysql 是主路径,必须拥有它来自 mysql 用户)

注意:从您提到的内容来看,您的系统中似乎不存在 mysql 用户。所以看起来创建用户的家庭路径为 /var/lib/mysql 应该可以解决问题。