因此,升级我的 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/ 中没有日志。有任何想法吗?
答案1
这行:
-su: 29: /usr/share/bash-completion/bash_completion: [[: not found
告诉我 /bin/sh 不是 bash shell(在现代 Debian 上,它几乎肯定是 dash),但它试图获取 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。