Upstart 无法启动 MySQL

Upstart 无法启动 MySQL

安装 MySQL 后,我收到一些错误,无法运行 MySQL 守护程序。我尝试卸载并重新安装几次,但我不知道发生了什么。

以下是我所看到的片段:

Setting up mysql-server-5.5 (5.5.31-0ubuntu0.13.04.1) ...
runlevel:/var/run/utmp: No such file or directory
initctl: Unknown job: mysql

sudo service mysql start出现unknown job错误,并且mysqld在我的系统上找不到。

我不知道接下来该怎么做,除了从源代码编译并创建自己的 upstart 脚本。当然,如果可能的话,我想用简单的方法做事。

我怎样才能成功运行 MySQL 或修复此问题?

以下是我运行安装命令时发生的情况的完整日志:

sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libaio1 libdbd-mysql-perl libdbi-perl libnet-daemon-perl libplrpc-perl libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5
  mysql-server-5.5 mysql-server-core-5.5
Suggested packages:
  tinyca mailx
The following NEW packages will be installed:
  libaio1 libdbd-mysql-perl libdbi-perl libnet-daemon-perl libplrpc-perl libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-server
  mysql-server-5.5 mysql-server-core-5.5
0 upgraded, 11 newly installed, 0 to remove and 13 not upgraded.
Need to get 0 B/25.4 MB of archives.
After this operation, 88.0 MB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Preconfiguring packages ...
Selecting previously unselected package libaio1:i386.
(Reading database ... 159063 files and directories currently installed.)
Unpacking libaio1:i386 (from .../libaio1_0.3.109-3_i386.deb) ...
Selecting previously unselected package libnet-daemon-perl.
Unpacking libnet-daemon-perl (from .../libnet-daemon-perl_0.48-1_all.deb) ...
Selecting previously unselected package libplrpc-perl.
Unpacking libplrpc-perl (from .../libplrpc-perl_0.2020-2_all.deb) ...
Selecting previously unselected package libdbi-perl.
Unpacking libdbi-perl (from .../libdbi-perl_1.622-1_i386.deb) ...
Selecting previously unselected package libdbd-mysql-perl.
Unpacking libdbd-mysql-perl (from .../libdbd-mysql-perl_4.021-1_i386.deb) ...
Selecting previously unselected package mysql-client-core-5.5.
Unpacking mysql-client-core-5.5 (from .../mysql-client-core-5.5_5.5.31-0ubuntu0.13.04.1_i386.deb) ...
Selecting previously unselected package libterm-readkey-perl.
Unpacking libterm-readkey-perl (from .../libterm-readkey-perl_2.30-4build4_i386.deb) ...
Selecting previously unselected package mysql-client-5.5.
Unpacking mysql-client-5.5 (from .../mysql-client-5.5_5.5.31-0ubuntu0.13.04.1_i386.deb) ...
Selecting previously unselected package mysql-server-core-5.5.
Unpacking mysql-server-core-5.5 (from .../mysql-server-core-5.5_5.5.31-0ubuntu0.13.04.1_i386.deb) ...
Selecting previously unselected package mysql-server-5.5.
Unpacking mysql-server-5.5 (from .../mysql-server-5.5_5.5.31-0ubuntu0.13.04.1_i386.deb) ...
Selecting previously unselected package mysql-server.
Unpacking mysql-server (from .../mysql-server_5.5.31-0ubuntu0.13.04.1_all.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
Setting up libaio1:i386 (0.3.109-3) ...
Setting up libnet-daemon-perl (0.48-1) ...
Setting up libplrpc-perl (0.2020-2) ...
Setting up libdbi-perl (1.622-1) ...
Setting up libdbd-mysql-perl (4.021-1) ...
Setting up mysql-client-core-5.5 (5.5.31-0ubuntu0.13.04.1) ...
Setting up libterm-readkey-perl (2.30-4build4) ...
Setting up mysql-client-5.5 (5.5.31-0ubuntu0.13.04.1) ...
Setting up mysql-server-core-5.5 (5.5.31-0ubuntu0.13.04.1) ...
Setting up mysql-server-5.5 (5.5.31-0ubuntu0.13.04.1) ...
runlevel:/var/run/utmp: No such file or directory
initctl: Unknown job: mysql
runlevel:/var/run/utmp: No such file or directory
initctl: Unknown job: mysql
Setting up mysql-server (5.5.31-0ubuntu0.13.04.1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

这是运行 apt-get 命令安装后 /var/log/mysql/error.log 的内容。

130518 12:14:36 [Note] Plugin 'FEDERATED' is disabled.
130518 12:14:36 InnoDB: The InnoDB memory heap is disabled
130518 12:14:36 InnoDB: Mutexes and rw_locks use GCC atomic builtins
130518 12:14:36 InnoDB: Compressed tables use zlib 1.2.7
130518 12:14:36 InnoDB: Using Linux native AIO
130518 12:14:36 InnoDB: Initializing buffer pool, size = 128.0M
130518 12:14:36 InnoDB: Completed initialization of buffer pool
130518 12:14:36 InnoDB: highest supported file format is Barracuda.
130518 12:14:36  InnoDB: Waiting for the background threads to start
130518 12:14:37 InnoDB: 5.5.31 started; log sequence number 1595675
130518 12:14:37  InnoDB: Starting shutdown...
130518 12:14:38  InnoDB: Shutdown completed; log sequence number 1595675
130518 12:14:38 [Note] Plugin 'FEDERATED' is disabled.
130518 12:14:38 InnoDB: The InnoDB memory heap is disabled
130518 12:14:38 InnoDB: Mutexes and rw_locks use GCC atomic builtins
130518 12:14:38 InnoDB: Compressed tables use zlib 1.2.7
130518 12:14:38 InnoDB: Using Linux native AIO
130518 12:14:38 InnoDB: Initializing buffer pool, size = 128.0M
130518 12:14:38 InnoDB: Completed initialization of buffer pool
130518 12:14:38 InnoDB: highest supported file format is Barracuda.
130518 12:14:38  InnoDB: Waiting for the background threads to start
130518 12:14:39 InnoDB: 5.5.31 started; log sequence number 1595675
ERROR: 1064  You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AL
TER TABLE user ADD column Show_view_priv enum('N','Y') CHARACTER SET utf8 NOT ' at line 1
130518 12:14:39 [ERROR] Aborting

130518 12:14:39  InnoDB: Starting shutdown...
130518 12:14:40  InnoDB: Shutdown completed; log sequence number 1595675
130518 12:14:40 [Note] /usr/sbin/mysqld: Shutdown complete

答案1

看起来许多应用程序都依赖于/var/run/utmp登录会话信息。

sudo touch /var/run/utmp
sudo chmod 664 /var/run/utmp
sudo reboot

重启后,按照@coteyr 的建议执行这些命令,全新安装 mysql

sudo apt-get purge mysql-server
sudo apt-get update
sudo apt-get install mysql-server 

这应该可以解决你的问题。

编辑:

sudo apt-get purge mysql-server
sudo apt-get purge mysql-common
sudo rm -rf /var/log/mysql
sudo rm -rf /var/log/mysql.*
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql
sudo apt-get install mysql-server --fix-missing --fix-broken

这似乎对很多人都有效,因为博客文章

答案2

该问题与 MySql 没有直接关系。init 守护进程控制工具未启动 mysql 服务器守护进程/etc/init

您可以手动恢复:

sudo initctl reload-configuration

现在 mysql 服务器按预期启动。

答案3

关于未知的工作,我使用这个解决了

sudo /etc/init.d/mysql start

而不是这个

sudo service mysql start

这里我提到

答案4

sudo apt-get install mysql-server

然后,一旦安装完成,确保/var/lib/mysql它存在并且/etc/init.d/mysql存在。/usr/bin/mysqld并且/usr/bin/mysqld_safe也应该存在。

如果仍然有问题,那么软件包有问题(假设没有错误)。您可以“清除”它,“更新”然后“安装”软件包,看看是否能清除错误。

sudo apt-get purge mysql-server
sudo apt-get update
sudo apt-get install mysql-server

如果这仍然不起作用,您将需要向软件包维护人员提交错误报告。

相关内容