我正在托管一个本地 LAMP 服务器,并在其上安装了 Magento(在/var/www/html/magento
),它运行正常,但是今晚我设法破坏了一些东西。
我在 Magento 设置过程中遇到了问题(老实说,我不记得是什么了),这促使我运行chmod -R -777 /var/
并chown -R travis /var/
授予其中所有文件的权限。
chmod -R -755 /var/www/
这导致了 Apache 403 错误,我通过运行和解决了该错误chown -R root /var/
。使用 修复了进一步的权限问题chmod -R -777 /var/www/html/magento
。
快进到现在
我无法启动 MySQL 服务。以下是我得到的信息:
travis@travis: service mysql stop
travis@travis: service mysql start
Job for mysql.service failed. See "systemctl status mysql.service" and "journalctl -xe" for details.
travis@travis:/etc/mysql$ systemctl status mysql.service -l
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) (Result: exit-code) since Wed 2015-06-17 23:01:24 EDT; 7min ago
Process: 31638 ExecStart=/usr/bin/mysqld_safe (code=exited, status=2)
Process: 31635 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 31638 (code=exited, status=2); : 31639 (mysql-systemd-s)
CGroup: /system.slice/mysql.service
└─control
├─ 1072 sleep 1
└─31639 /bin/bash /usr/share/mysql/mysql-systemd-start post
Jun 17 23:01:24 travis systemd[1]: Starting MySQL Community Server...
Jun 17 23:01:24 travis mysqld_safe[31638]: 150617 23:01:24 mysqld_safe Can't log to error log and syslog at the same time. Remove all --log-error configuration options for --syslog to take effect.
Jun 17 23:01:24 travis mysqld_safe[31638]: 150617 23:01:24 mysqld_safe Logging to '/var/log/mysql/error.log'.
Jun 17 23:01:24 travis mysqld_safe[31638]: touch: cannot touch ‘/var/log/mysql/error.log’: Permission denied
Jun 17 23:01:24 travis mysqld_safe[31638]: chmod: cannot access ‘/var/log/mysql/error.log’: Permission denied
Jun 17 23:01:24 travis mysqld_safe[31638]: 150617 23:01:24 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Jun 17 23:01:24 travis mysqld_safe[31638]: /usr/bin/mysqld_safe: 126: /usr/bin/mysqld_safe: cannot create /var/log/mysql/error.log: Permission denied
Jun 17 23:01:24 travis mysqld_safe[31638]: /usr/bin/mysqld_safe: 1: eval: cannot create /var/log/mysql/error.log: Permission denied
Jun 17 23:01:24 travis systemd[1]: mysql.service: main process exited, code=exited, status=2/INVALIDARGUMENT
现在,我的 Magento 网站127.0.0.1/magento/
显示一个错误页面,其中包含以下内容:
SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111)
答案1
经过货物,我能够通过授予root
组访问权限来使一切恢复正常/var/log/mysql
。然后我重新启动了 mysql 服务sudo service mysql restart
,一切恢复正常。
答案2
编辑:读完快进之前发生的事情后,我想我会重新安装整个操作系统。整个 /var 结构中有太多不同的权限。(为什么有人会建议“chmod -R 777 /var”?)