Linux

mysql 無法啟動 bash_completion 錯誤

  • July 28, 2014

因此,在升級我的 debian 系統後,mysql 不再使用命令“service mysql start”啟動。我得到:

Job for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details. linksys:/home/users/stan# journalctl -xn
-- Logs begin at Mon 2014-07-28 10:03:56 PDT, end at Mon 2014-07-28 12:07:07 PDT.
-- Jul 28 12:07:07 linksys mysql[5509]: -su: 89: /usr/share/bash-completion/bash_completion: complete: not found 
  Jul 28 12:07:07 linksys mysql[5509]: -su: 92: /usr/share/bash-completion/bash_completion: complete: not found 
  Jul 28 12:07:07 linksys mysql[5509]: -su: 101: /usr/share/bash-completion/bash_completion: Syntax error: "(" unexpected (expec 
  Jul 28 12:07:07 linksys su[5536]: pam_unix(su:session): session closed for user mysql
  Jul 28 12:07:07 linksys systemd[1]: mysql.service: control process exited, code=exited status=2
  Jul 28 12:07:07 linksys systemd[1]: Failed to start LSB: Start and stop the mysql database server daemon.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mysql.service has failed.

看起來/etc/init.d/mysql啟動mysql的命令是:su - mysql -s /bin/sh -c "/usr/bin/mysqld_safe > /dev/null 2>&1 &"但我得到更多的bash_completion錯誤:

-su: 29: /usr/share/bash-completion/bash_completion: [[: not found
-su: 35: /usr/share/bash-completion/bash_completion: [[: not found
-su: 51: /usr/share/bash-completion/bash_completion: shopt: not found
-su: 57: /usr/share/bash-completion/bash_completion: complete: not found
-su: 62: /usr/share/bash-completion/bash_completion: complete: not found
-su: 65: /usr/share/bash-completion/bash_completion: complete: not found
-su: 68: /usr/share/bash-completion/bash_completion: complete: not found
-su: 71: /usr/share/bash-completion/bash_completion: complete: not found
-su: 74: /usr/share/bash-completion/bash_completion: complete: not found
-su: 77: /usr/share/bash-completion/bash_completion: complete: not found
-su: 80: /usr/share/bash-completion/bash_completion: complete: not found
-su: 83: /usr/share/bash-completion/bash_completion: complete: not found
-su: 86: /usr/share/bash-completion/bash_completion: complete: not found
-su: 89: /usr/share/bash-completion/bash_completion: complete: not found
-su: 92: /usr/share/bash-completion/bash_completion: complete: not found
-su: 101: /usr/share/bash-completion/bash_completion: Syntax error: "(" unexpected (expecting "}")

/var/log/mysql/ 中沒有日誌。有任何想法嗎?

這一行:

-su: 29: /usr/share/bash-completion/bash_completion: [[: not found

告訴我 /bin/sh 不是 bash shell(在現代 Debian 上,幾乎可以肯定是破折號),但它正在嘗試獲取 bash 腳本。因此,您需要回答的問題是為什麼非 bash shell 會嘗試獲取 bash_completion 腳本。我猜問題是mysql使用者主目錄中的點文件之一。

嘗試執行:

grep bash_completion ~mysql/.*

找出哪一個。我有根據的猜測是 mysql 使用者.profile在他的主目錄中有一個嘗試執行 bash 命令而不檢查他所在的 shell 是否是 bash。

或者,讓事情重新啟動和執行的最簡單的修復方法可能是將 /bin/sh 切換為 bash 而不是 dash。根據https://wiki.debian.org/DashAsBinSh,您可以通過執行:

sudo dpkg-reconfigure dash

並按照螢幕上的一些提示將 /bin/sh 設置回 bash。

引用自:https://unix.stackexchange.com/questions/147067