安装 mysql 时出错,有什么办法可以修复吗?

安装 mysql 时出错,有什么办法可以修复吗?

我之前安装过 mysql apt-get install mysql-server(就像我一直做的那样),我之前做过一个apt-get update(我使用的是 Debian 6),安装的时候我发现了这个问题,我觉得这很常见,但是我按照所有的步骤操作了,但没有任何效果。

apt-get install -f 我还尝试过使用apt-get remove mysql-server(和common,和mysql-server-5.1)以及使用apt-get purge(每个包)和更高版本install,但没有任何效果......

我也试过了

dpkg-reconfigure mysql-server-5.1
apt-get install --reinstall mysql-server
(all runed as Root)

仍然没有任何效果,有什么想法吗???

130130 10:11:48  InnoDB: Shutdown completed; log sequence number 0 44233
Starting MySQL database server: mysqld . . . . . . . . . . . . . . failed!
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.1 (--configure):
subprocess installed post-installation script returned error exit status 1
configured to not write apport reports

    dpkg: dependency problems prevent configuration of mysql-server:

mysql-server depends on mysql-server-5.1; however:
Package mysql-server-5.1 is not configured yet.
dpkg: error processing mysql-server (--configure):
dependency problems - leaving unconfigured
configured to not write apport reports
Errors were encountered while processing:
     mysql-server-5.1
     mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

当我尝试

dpkg-reconfigure mysql-server-5.1


/usr/sbin/dpkg-reconfigure: mysql-server-5.1 is broken or not fully installed

/etc/init.d/mysql 上的“Start”案例是

'start')
        sanity_checks;
        # Start daemon
        log_daemon_msg "Starting MySQL database server" "mysqld"
        if mysqld_status check_alive nowarn; then
           log_progress_msg "already running"
           log_end_msg 0
        else
            # Could be removed during boot
            test -e /var/run/mysqld || install -m 755 -o mysql -g root -d /var/run/mysqld

            # Start MySQL!
            /usr/bin/mysqld_safe > /dev/null 2>&1 &

            # 6s was reported in #352070 to be too few when using ndbcluster
            for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14; do
                sleep 1
                if mysqld_status check_alive nowarn ; then break; fi
                log_progress_msg "."
            done
            if mysqld_status check_alive warn; then
                log_end_msg 0
                # Now start mysqlcheck or whatever the admin wants.
                output=$(/etc/mysql/debian-start)
                [ -n "$output" ] && log_action_msg "$output"
            else
                log_end_msg 1
                log_failure_msg "Please take a look at the syslog"
            fi
        fi

当我使 mysql 强制重新加载时:

Reloading MySQL database server: mysqld/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
root@americandougnuts:/etc/init.d#
root@americandougnuts:/etc/init.d# Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!

答案1

由于某种原因,apt-get upgrade 创建了一个没有正确所有权的新 mysql bin 文件。此文件位于 /var/lib/mysql。由于 mysql 无法访问此文件,因此 mysql 无法启动,升级失败。

检查 /var/lib/mysql 中文件的文件所有权

ls -ltra /var/lib/mysql


-rw-rw----  1 mysql root        125 Oct 29 09:53 mysql-bin.000288
-rw-rw----  1 mysql root        125 Oct 29 09:53 mysql-bin.000289
-rw-rw----  1 mysql mysql       228 Oct 29 10:07 mysql-bin.index
-rw-rw----  1 root  root        125 Oct 29 10:07 mysql-bin.000291
-rw-rw----  1 root  root        125 Oct 29 10:07 mysql-bin.000290

肮脏的解决方法:

  • 打开第二个终端
  • 当 true 时;执行 chown mysql:mysql /var/lib/mysql/*;完成

  • 在原始终端中

  • apt-get 升级 -y

当升级成功完成时 CRT+C 第二个终端中的 while 循环。

答案2

它说明了为什么它在您共享的输出中不起作用:

Starting MySQL database server: mysqld . . . . . . . . . . . . . . failed!

MySQL 拒绝启动,检查 MySQL 的日志文件/var/log以找出原因,修复它并dpkg-reconfigure再次运行。

答案3

只需在 shell 中以 root 身份运行“mysqld”即可启动 mysql。然后它应该会在屏幕上打印启动失败的原因。通常,这是 /etc/mysql/my.cnf 中过时的配置选项。

纠正阻止 mysql 启动的错误后,重新运行dpkg-reconfigure mysql-server-5.1

相关内容