MySQL 作业无法启动

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22909060/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 20:23:12  来源:igfitidea点击:

MySQL Job failed to start

mysqlubuntu-12.04

提问by Alfred

I'm on Kubuntu 12.04, and after installing mysql via an apt-get (mysql ver: 5.5.35), i'm trying to start mysql service, but I got this error:

我在 Kubuntu 12.04 上,在通过 apt-get(mysql 版本:5.5.35)安装 mysql 后,我正在尝试启动 mysql 服务,但出现此错误:

sudo service mysql start

start: Job failed to start

须藤服务 mysql 启动

开始:作业未能启动

So I googled this problem, it says i have to go to the /var/log/mysql/error.log

所以我用谷歌搜索了这个问题,它说我必须去/var/log/mysql/error.log

But my error.log file is empty :(

但是我的 error.log 文件是空的 :(

Then I checked the permissions :

然后我检查了权限:

drwxr-s--- 2 mysql adm 4096 Apr 7 11:21 mysql

-rw-r----- 1 mysql adm 0 Apr 7 11:21 error.log

drwxr-s--- 2 mysql adm 4096 Apr 7 11:21 mysql

-rw-r----- 1 mysql adm 0 Apr 7 11:21 error.log

So I don't know what to do... Why this error ? Why is the error file empty ?

所以我不知道该怎么办...为什么会出现这个错误?为什么错误文件是空的?

回答by Rajesh

First make a backup of your /var/lib/mysql/ directory just to be safe.

为了安全起见,首先备份您的 /var/lib/mysql/ 目录。

sudo mkdir /home/<your username>/mysql/
cd /var/lib/mysql/
sudo cp * /home/<your username>/mysql/ -R

Next purge MySQL (this will remove php5-mysql and phpmyadmin as well as a number of other libraries so be prepared to re-install some items after this.

接下来清除 MySQL(这将删除 php5-mysql 和 phpmyadmin 以及许多其他库,因此准备在此之后重新安装一些项目。

sudo apt-get purge mysql-server-5.1 mysql-common

Remove the folder /etc/mysql/ and it's contents

删除文件夹 /etc/mysql/ 及其内容

sudo rm /etc/mysql/ -R

Next check that your old database files are still in /var/lib/mysql/ if they are not then copy them back in to the folder then chown root:root

接下来检查您的旧数据库文件是否仍在 /var/lib/mysql/ 中,如果它们不在,则将它们复制回文件夹中,然后 chown root:root

(only run these if the files are no longer there)

(仅当文件不再存在时才运行这些)

sudo mkdir /var/lib/mysql/
sudo chown root:root /var/lib/mysql/ -R
cd ~/mysql/
sudo cp * /var/lib/mysql/ -R

Next install mysql server

接下来安装mysql服务器

sudo apt-get install mysql-server

Finally re-install any missing packages like phpmyadmin and php5-mysql.

最后重新安装任何丢失的软件包,如 phpmyadmin 和 php5-mysql。

回答by blindJustice

My problem was running out of memory. Digital ocean has great instruction for adding swap memory for Ubuntu: https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

我的问题是内存不足。数字海洋对为 Ubuntu 添加交换内存有很好的说明:https: //www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

This solved the issue and enabled me to restart the Mysql that otherwise would not start.

这解决了问题并使我能够重新启动否则无法启动的 Mysql。

回答by mootmoot

Reinstallation will works because it will reset all the value to default. It is better to find what the real culprits (my.cnf editing mistake does happens, e.g. bad/outdated parameter suggestion during mysql tuning.)

重新安装将起作用,因为它将所有值重置为默认值。最好找出真正的罪魁祸首(my.cnf 编辑错误确实发生了,例如在 mysql 调整期间错误/过时的参数建议。)

Here is the mysql diagnosis if you suspect some value is wrong inside my.cnf : Run the mysqld to show you the results.

如果您怀疑 my.cnf 中的某些值有误,这里是 mysql 诊断: 运行 mysqld 以显示结果。

sudo -u mysql  mysqld 

Afterwards, fix all the my.cnf key error that pop out from the screen until mysqld startup successfully.

之后,修复所有从屏幕弹出的 my.cnf 键错误,直到 mysqld 启动成功。

Then restart it using

然后使用重新启动它

sudo service mysql restart

回答by Rao

In most cases, just purging the mysql-server package and re-installing it will do the job.

在大多数情况下,只需清除 mysql-server 包并重新安装它就可以完成这项工作。

Run,

跑,

sudo apt-get purge mysql-server-5.1 mysql-common

sudo apt-get purge mysql-server-5.1 mysql-common

followed by

其次是

sudo apt-get install mysql-server

sudo apt-get install mysql-server

回答by Orange

In my case, it simply because the disk is full. Just clear some disk space and restart and everything is fine.

就我而言,这仅仅是因为磁盘已满。只需清除一些磁盘空间并重新启动,一切都很好。

回答by Dileep

This line did solve the issue in my case,

这条线确实解决了我的问题,

sudo apt clean

回答by barresoft

In my case, i do:

就我而言,我这样做:

  1. sudo nano /etc/mysql/my.cnf
  2. search for bindnames and IPs
  3. remove the specific, and let only localhost 127.0.0.1 and the hostname
  1. sudo nano /etc/mysql/my.cnf
  2. 搜索bind名称和 IP
  3. 删除特定的,只让 localhost 127.0.0.1 和主机名

回答by ks1bbk

Check the file permissions, if edited

检查文件权限(如果已编辑)

Fail:

失败:

$ sudo chmod 776 /etc/mysql/my.cnf
$ sudo service mysql restart
mysql stop/waiting
start: Job failed to start

Ok:

好的:

$ sudo chmod 774 /etc/mysql/my.cnf
$ sudo service mysql restart
stop: Unknown instance:
mysql start/running, process 9564

回答by Asif Shahzad

The given solution requires enough free HDD, the actual problem was the HDD memory shortage. So If you don't have an alternative server or free disk space, you need some other alternative.

给定的解决方案需要足够的可用硬盘,实际问题是硬盘内存不足。因此,如果您没有替代服务器或可用磁盘空间,则需要其他替代方法。

I faced this error with my production server (Linode VPS) when I was running a bulk download into MySQL. Its not a proper solution but VERY QUICK FIX, which we often need in production to bring things UP FAST.

当我运行批量下载到 MySQL 时,我的生产服务器 (Linode VPS) 遇到了这个错误。它不是一个合适的解决方案,而是非常快速的修复,我们在生产中经常需要它来快速启动。

  1. Resize our VPS Server to higher Hard Disk size
  2. Start MySQL, it works.
  3. Login to your MySQL instance and make appropriate adjustments that caused this error (e.g. remove some records, table, or take DB backup to your local machine that are not required at production, etc. After all you know, what caused this issue.)
  4. Downgrade your VPS Server to previous package you was already using
  1. 将我们的 VPS 服务器调整为更高的硬盘大小
  2. 启动 MySQL,它的工作原理。
  3. 登录您的 MySQL 实例并进行导致此错误的适当调整(例如,删除一些记录、表或将 DB 备份到您的本地机器,这些在生产中不需要,等等。毕竟您知道导致此问题的原因。)
  4. 将您的 VPS 服务器降级到您已经在使用的先前软件包

回答by Nikolas Soares

In my case:

就我而言:

  • restart server
  • restart mysql
  • create .socket in directory
  • 重启服务器
  • 重启mysql
  • 在目录中创建 .socket