【发布时间】:2020-05-27 03:45:22
【问题描述】:
我安装了 mysql 5.7 但后来发现我需要 mysql 5.6 所以我删除了所有与 mysql 相关的包
apt-get remove --purge mysql*
所以它被删除了。然后我发出:
apt-get install mysql-server-5.6 mysql-client-5.6
所以安装了提到的软件包。
但它没有开始使用systemctl start mysql 或service mysql start 甚至重新启动。结果是这样的:
service mysql restart
or
service mysql start
or
systemctl restart mysql
or
systemctl start mysql
返回:
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
但是
systemctl status mysql
返回
mysql.service - LSB: Start and stop the mysql database server daemon
Loaded: loaded (/etc/init.d/mysql; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2017-04-10 13:24:00 EDT; 29s ago
Docs: man:systemd-sysv-generator(8)
Process: 15820 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)
Main PID: 1323 (code=exited, status=0/SUCCESS)
Apr 10 13:23:30 server mysqld[15926]: 2017-04-10 13:23:30 15925 [Note] InnoDB: Compressed tables use zlib 1.2.8
Apr 10 13:23:30 server mysqld[15926]: 2017-04-10 13:23:30 15925 [Note] InnoDB: Using Linux native AIO
Apr 10 13:23:30 server mysqld[15926]: 2017-04-10 13:23:30 15925 [Note] InnoDB: Using CPU crc32 instructions
Apr 10 13:23:30 server mysqld[15926]: 2017-04-10 13:23:30 15925 [Note] InnoDB: Initializing buffer pool, size = 128.0M
Apr 10 13:23:30 server mysqld[15926]: 2017-04-10 13:23:30 15925 [Note] InnoDB: Completed initialization of buffer pool
Apr 10 13:24:00 server mysql[15820]: ...fail!
Apr 10 13:24:00 server systemd[1]: mysql.service: Control process exited, code=exited status=1
Apr 10 13:24:00 server systemd[1]: Failed to start LSB: Start and stop the mysql database server daemon.
Apr 10 13:24:00 server systemd[1]: mysql.service: Unit entered failed state.
Apr 10 13:24:00 server systemd[1]: mysql.service: Failed with result 'exit-code'.
什么是Failed to start LSB: Start and stop the mysql database server daemon.
在安装 5.6 之前,5.7 版本运行良好,但现在它是这样的。
/var/log/mysql/errors.log 是空的,这些是/var/log/syslog 最后几行
Apr 10 13:23:30 server mysqld: 2017-04-10 13:23:30 15925 [Note] InnoDB: Completed initialization of buffer pool
Apr 10 13:23:30 server mysqld_safe: mysqld from pid file /var/lib/mysql/server.pid ended
Apr 10 13:24:00 server /etc/init.d/mysql[16277]: 0 processes alive and '/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping' resulted in
Apr 10 13:24:00 server /etc/init.d/mysql[16277]: #007/usr/bin/mysqladmin: connect to server at 'localhost' failed
Apr 10 13:24:00 server /etc/init.d/mysql[16277]: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Apr 10 13:24:00 server /etc/init.d/mysql[16277]: Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
Apr 10 13:24:00 server /etc/init.d/mysql[16277]:
Apr 10 13:24:00 server mysql[15820]: ...fail!
Apr 10 13:24:00 server systemd[1]: mysql.service: Control process exited, code=exited status=1
Apr 10 13:24:00 server systemd[1]: Failed to start LSB: Start and stop the mysql database server daemon.
Apr 10 13:24:00 server systemd[1]: mysql.service: Unit entered failed state.
Apr 10 13:24:00 server systemd[1]: mysql.service: Failed with result 'exit-code'.
mysqld_safe 的输出
170410 13:33:28 mysqld_safe Logging to syslog.
170410 13:33:28 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
170410 13:33:28 mysqld_safe mysqld from pid file /var/lib/mysql/server.pid ended
这是我的/etc/mysql/my.cnf,没有/etc/my.cnf
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
!includedir /etc/mysql/conf.d/
【问题讨论】:
-
能否查看MySQL进程服务器日志。大概在
/var/log/mysql/ -
/var/log/mysql/errors.log 为空。我更新了问题,请再看看。谢谢 -
你能检查手动启动进程的输出吗?只需运行
mysqld_safe -
输出为:
170410 13:33:28 mysqld_safe Logging to syslog. 170410 13:33:28 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 170410 13:33:28 mysqld_safe mysqld from pid file /var/lib/mysql/server.pid ended -
我假设您在 /etc/my.cnf 中仍有一个配置文件,其中包含特定于 5.7 的参数,现在尝试将其加载到 5.6 会导致错误。尝试使用默认配置文件启动。此外,距离您提出问题仅 15 分钟,放松,等待正确答案。
标签: mysql ubuntu-16.04