为什么mysqld一直在后台运行?

为什么mysqld一直在后台运行?

我注意到mysqld始终在后台运行。每次启动时它都会启动,即使我将其关闭后,它也会重新启动。我已使用以下命令删除了与 mysql 相关的所有内容:

sudo apt-get remove --purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean

但是,它仍然显示在 中ps -aux。这是什么意思?另外,ps -aux 输出中的用户 27 是什么意思?我不记得创建过用户 27。

说明:事实上,这是由于后台运行的 sql docker 容器造成的

答案1

听起来你有一个正在运行的包含 mysqld 的 docker 容器。

答案2

我发现 mysqld 正在我的系统上运行并占用了超过 3GB 的 RAM。

我开始调查以下内容:

sudo service --status-all

其中将 mysql 列为正在运行的项目之一(我也在系统监视器中看到了它)。

我的系统上没有安装 Docker。

然后我看了一下服务脚本:

$ cat /etc/init.d/mysql

以下是该脚本的部分列表:

#!/bin/bash
#
### BEGIN INIT INFO
# Provides:          mysql
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Should-Start:      $network $time
# Should-Stop:       $network $time
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start and stop the mysql database server daemon
# Description:       Controls the main MySQL database server daemon "mysqld"
#                    and its wrapper script "mysqld_safe".
### END INIT INFO
#
set -e
set -u
${DEBIAN_SCRIPT_DEBUG:+ set -v -x}

test -x /usr/bin/mysqld_safe || exit 0

. /lib/lsb/init-functions

SELF=$(cd $(dirname $0); pwd -P)/$(basename $0)
CONF=/etc/mysql/my.cnf
MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"

# priority can be overriden and "-s" adds output to stderr
ERR_LOGGER="logger -p daemon.err -t /etc/init.d/mysql -i"

# Safeguard (relative paths, core dumps..)
cd /
umask 077

# mysqladmin likes to read /root/.my.cnf. This is usually not what I want
# as many admins e.g. only store a password without a username there and
# so break my scripts.
export HOME=/etc/mysql/

## Fetch a particular option from mysql's invocation.
#
# Usage: void mysqld_get_param option
mysqld_get_param() {
    /usr/sbin/mysqld --print-defaults \
        | tr " " "\n" \
        | grep -- "--$1" \
        | tail -n 1 \
        | cut -d= -f2
}

## Do some sanity checks before even trying to start mysqld.
sanity_checks() {
  # check for config file
  if [ ! -r /etc/mysql/my.cnf ]; then
    log_warning_msg "$0: WARNING: /etc/mysql/my.cnf cannot be read. See README.Debian.gz"
    echo                "WARNING: /etc/mysql/my.cnf cannot be read. See README.Debian.gz" | $ERR_LOGGER
  fi

但是,这是从哪里来的?我安装的其他东西是否将 mysql 添加到我的系统中?我记得没有这样做,而且为什么它在我启动机器时启动?

我搜索了 Snaps、Ubuntu 软件和其他各种地方,但似乎我还没有自己安装 Mysql。

也许安装了 Java EE 之类的?可能就是这样。

我运行了以下命令:

sudo systemctl --all list-unit-files --type=service

我看到 mysql 列出了以下内容:

UNIT_FILE                        STATE           VENDOR PRESET
mysql.service                    enabled         enabled

然后我需要在启动时禁用该服务,因此我运行了以下命令:

sudo systemctl disable mysql.service

我再次运行检查,发现它确实已被禁用:

UNIT_FILE                        STATE           VENDOR PRESET
mysql.service                    disabled         enabled

相关内容