我注意到mysqld始終在背景運行。它在每次啟動時啟動,即使在我殺死它之後,它也會重新啟動。我已經刪除了與 mysql 相關的所有內容:
sudo apt-get remove --purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
然而,它仍然出現在ps -aux
.這個東西的意思是什麼 ?另外,使用者 27 在 ps -aux 的輸出中是什麼意思?我不記得創建過用戶 27。
說明:實際上是由於後台運行了sql docker容器
答案1
聽起來你有一個正在運行的 docker 容器,其中有 mysqld。
答案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