我是 Ubuntu 服务器和 MySql 的新手。我试图在 VirtualBox 中创建一个服务器,在部署到真实服务器之前,我可以使用它进行 Web 开发和测试。我在虚拟机中安装并运行了 Ubuntu 服务器 14.04.1。PHP 运行良好。我可以从主机上的 Web 浏览器访问我放在 /var/www/html 文件夹中的任何内容。我无法启动 MySql。我尝试卸载 Ubuntu 附带的版本,然后从 dev.mysql.com 上的 MySql 存储库重新安装,但它仍然无法启动。以前的版本给我一个“.sock”文件的错误,我记不起它的名字了。现在它只是说它无法启动,只说明日志文件无法访问。我在谷歌上搜索了将近两天,没有找到任何可行的解决方案。我对 Unix 终端还很陌生,所以如果我误解了,请原谅我。
MySql服务状态:
eric@Server:~$ sudo service mysql status
sudo: /var/lib/sudo owned by uid 1000, should be uid 0
[sudo] password for eric:
* MySQL Community Server 5.6.21 is not running
这是我尝试启动 MySql 时得到的结果:
eric@Server:~$ sudo service mysql start
sudo: /var/lib/sudo owned by uid 1000, should be uid 0
[sudo] password for eric:
No directory, logging in with HOME=/
touch: cannot touch ‘/var/log/mysql/error.log’: Permission denied
chmod: cannot access ‘/var/log/mysql/error.log’: Permission denied
/usr/bin/mysqld_safe: 129: /usr/bin/mysqld_safe: cannot create /var/log/mysql/error.log: Permission denied
/usr/bin/mysqld_safe: 1: eval: cannot create /var/log/mysql/error.log: Permission denied
touch: cannot touch ‘/var/log/mysql/error.log’: Permission denied
chown: cannot access ‘/var/log/mysql/error.log’: Permission denied
chmod: cannot access ‘/var/log/mysql/error.log’: Permission denied
/usr/bin/mysqld_safe: 129: /usr/bin/mysqld_safe: cannot create /var/log/mysql/error.log: Permission denied
......
* MySQL Community Server 5.6.21 did not start. Please check logs for more details.
这是 mysql --verbose --help (我从顶部剪掉了帮助部分)
eric@Server:~$ sudo mysql --verbose --help
sudo: /var/lib/sudo owned by uid 1000, should be uid 0
[sudo] password for eric:
mysql Ver 14.14 Distrib 5.6.21, for Linux (x86_64) using EditLine wrapper
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
[content cut]
Variables (--variable-name=value)
and boolean options {FALSE|TRUE} Value (after reading options)
--------------------------------- ----------------------------------------
auto-rehash TRUE
auto-vertical-output FALSE
bind-address (No default value)
character-sets-dir (No default value)
column-type-info FALSE
comments FALSE
compress FALSE
debug-check FALSE
debug-info FALSE
database (No default value)
default-character-set auto
delimiter ;
enable-cleartext-plugin FALSE
vertical FALSE
force FALSE
named-commands FALSE
ignore-spaces FALSE
init-command (No default value)
local-infile FALSE
no-beep FALSE
host (No default value)
html FALSE
xml FALSE
line-numbers TRUE
unbuffered FALSE
column-names TRUE
sigint-ignore FALSE
port 3306
prompt mysql>
quick FALSE
raw FALSE
reconnect TRUE
socket /var/run/mysqld/mysqld.sock
ssl FALSE
ssl-ca (No default value)
ssl-capath (No default value)
ssl-cert (No default value)
ssl-cipher (No default value)
ssl-key (No default value)
ssl-crl (No default value)
ssl-crlpath (No default value)
ssl-verify-server-cert FALSE
table FALSE
user (No default value)
safe-updates FALSE
i-am-a-dummy FALSE
connect-timeout 0
max-allowed-packet 16777216
net-buffer-length 16384
select-limit 1000
max-join-size 1000000
secure-auth TRUE
show-warnings FALSE
plugin-dir (No default value)
default-auth (No default value)
histignore (No default value)
binary-mode FALSE
connect-expired-password FALSE
如果您需要任何其他信息,请告诉我。我真的很想让它发挥作用,这样我就可以开始我的网络开发了。
提前感谢您的所有帮助!
埃里克
答案1
我怀疑这可能是 MySQL 用户运行执行的权限问题。请尝试运行以下命令并检查您的问题是否已解决。
chown mysql /var/run/mysqld
答案2
是的,这似乎是权限问题。从您的日志来看,您的 MySQL 无法在 中创建任何日志文件/var/log/mysql
,因此您应该将权限更改为 mysql 用户 : chown -R /var/log/mysql
,然后重新启动 mysql 进程。