2017-04-10 130 views
0

mysql的启动和重新启动的问题,我mysql安装5.7但后来发现我需要的mysql 5.6,所以我删除了所有MySQL相关的软件包与的ubuntu - Ubuntu的16.04服务器

apt-get remove --purge mysql* 

所以它得到了清除。然后我发出:

apt-get install mysql-server-5.6 mysql-client-5.6 

所以提到的软件包得到安装。 但它并未使用systemctl start mysqlservice 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 versio前n工作正常,但现在它是这样的。

/var/log/mysql/errors.log是空的,这些都是/var/log/syslog最后几行

输出 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 

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'. 

,这是我/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/ 
+0

你能检查MySQL进程服务器日志吗?可能在'/ var/log/mysql /' –

+0

'/var/log/mysql/errors'.log中为空。我更新了这个问题,请再看一次。谢谢 –

+0

你可以检查手动启动过程的输出吗?只需运行'mysqld_safe' –

回答

0

停止MySQL服务CE:

sudo service mysql stop 

删除的mysql:

sudo apt-get remove mysql 
sudo apt-get purge mysql 

然后发出在终端whereis mysql命令,并删除所有该命令使用rm -rf命令列出的位置。例如rm -rf /etc/mysql

然后重新安装你想要的mysql版本。所有应该按预期工作。

+0

我照你说的做了,但是'apt-get remove mysql'让我错误,所以我用'apt-get remove mysql *'和'sudo apt-get purge mysql *'。并删除命令abov中找到的目录,所以重新安装它,但它的钢是相同的。没有变化,没有开始 –

+0

是你的完整'mysql.cnf'文件吗? – coderodour

+0

是的。它的所有包含在my.cnf –