简体   繁体   English

MySQL 作业无法启动

[英]MySQL Job failed to start

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须藤服务 mysql 启动

start: Job failed to start开始:作业未能启动

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 drwxr-s--- 2 mysql adm 4096 Apr 7 11:21 mysql

-rw-r----- 1 mysql adm 0 Apr 7 11:21 error.log -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 ?为什么错误文件是空的?

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。

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。

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, eg 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

In my case, it simply because the disk is full.就我而言,这仅仅是因为磁盘已满。 Just clear some disk space and restart and everything is fine.只需清除一些磁盘空间并重新启动,一切都很好。

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

followed by其次是

sudo apt-get install mysql-server

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

sudo apt clean

In my case, i do:就我而言,我这样做:

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

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

To help others who do not have a full disk to troubleshoot this problem, first inspect your error log (for me the path is given in my /etc/mysql/my.cnf file):为了帮助没有完整磁盘的其他人解决此问题,首先检查您的错误日志(对我而言,路径在我的/etc/mysql/my.cnf文件中给出):

tail /var/log/mysql/error.log

My problem turned out to be a new IP address allocated after some network router reconfiguration, so I needed to change the bind-address variable.我的问题原来是在一些网络路由器重新配置后分配了一个新的 IP 地址,所以我需要更改bind-address变量。

In my case the problem was the /var/log disk full (check with df -h )在我的情况下,问题是/var/log磁盘已满(检查df -h

Just deleted some log files and mysql started, no big deal!只是删除了一些日志文件并启动了mysql,没什么大不了的!

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.当我运行批量下载到 MySQL 时,我的生产服务器 (Linode VPS) 遇到了这个错误。 Its not a proper solution but VERY QUICK FIX, which we often need in production to bring things UP FAST.它不是一个合适的解决方案,而是非常快速的修复,我们在生产中经常需要它来快速启动。

  1. Resize our VPS Server to higher Hard Disk size将我们的 VPS 服务器调整为更高的硬盘大小
  2. Start MySQL, it works.启动 MySQL,它的工作原理。
  3. Login to your MySQL instance and make appropriate adjustments that caused this error (eg 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.)登录您的 MySQL 实例并进行导致此错误的适当调整(例如,删除一些记录、表或将 DB 备份到您的本地机器,这些在生产中不需要,等等。毕竟您知道导致此问题的原因。)
  4. Downgrade your VPS Server to previous package you was already using将您的 VPS 服务器降级到您已经在使用的先前软件包

In my case:就我而言:

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

I had the same problem.我有同样的问题。 But i discover that my hd is full.但是我发现我的高清已满。

$ sudo cat /var/log/upstart/mysql.log
/proc/self/fd/9: ERROR: The partition with /var/lib/mysql is too full!

So, I run所以,我跑

$ df -h

And I got the message我收到了消息

/dev/xvda1      7.8G  7.4G     0 100% /

Then I found out which folder was full by running the following command on the terminal然后我通过在终端上运行以下命令找出哪个文件夹已满

$ cd /var/www
$ for i in *; do echo $i; find $i |wc -l; done

This give me the number of files on each folder on /var/www.这给了我 /var/www 上每个文件夹上的文件数。 I logged into the folder with most files, and deleted some backup files, and i continued deleting useless files and cache files.我登录了大多数文件的文件夹,并删除了一些备份文件,我继续删除了无用的文件和缓存文件。

then I run $ sudo /etc/init.d/mysql start and it work again然后我运行 $ sudo /etc/init.d/mysql start 并再次运行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM