2017-04-10 156 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 –