2017年2月22日 星期三

樹莓派 MySQL/phpMyAdmin 無法登入問題

前天晚上登入樹莓派 B 的 phpMyAdmin 時發現登入失敗, 出現如下錯誤訊息 :

"#2002 - Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) — 伺服器沒有回應(或者是伺服器的 socket 沒有被正確的設定)。"

"mysqli_real_connect(): (HY000/2002): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)"


想從命令列進入 mysql shell 也失敗 :

pi@raspberrypi:~ $ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

重新啟動 MySQL 伺服器也失敗 :

$ sudo /etc/init.d/mysql restart

pi@raspberrypi:~ $ sudo /etc/init.d/mysql restart
[....] Restarting mysql (via systemctl): mysql.serviceJob for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.
 failed!

照錯誤訊息下 systemctl 指令, 結果還是無法啟動 MySQL 伺服器 :

pi@raspberrypi:~ $ sudo systemctl status mysql.service -l
● mysql.service - LSB: Start and stop the mysql database server daemon
   Loaded: loaded (/etc/init.d/mysql)
   Active: failed (Result: exit-code) since Tue 2017-02-21 06:51:17 CST; 13min ago
  Process: 24848 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)

Feb 21 06:51:17 raspberrypi /etc/init.d/mysql[25575]: 0 processes alive and '/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping' resulted in
Feb 21 06:51:17 raspberrypi mysql[24848]: Starting MySQL database server: mysqld . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . failed!
Feb 21 06:51:17 raspberrypi systemd[1]: mysql.service: control process exited, code=exited status=1
Feb 21 06:51:17 raspberrypi systemd[1]: Failed to start LSB: Start and stop the mysql database server daemon.
Feb 21 06:51:17 raspberrypi systemd[1]: Unit mysql.service entered failed state.

而 journalctl 指令的回應如下 : 

pi@raspberrypi:~ $ sudo journalctl -xn
-- Logs begin at Mon 2017-02-20 22:59:07 CST, end at Tue 2017-02-21 07:13:18 CST. --
Feb 21 07:10:04 raspberrypi CRON[26287]: pam_unix(cron:session): session closed for user pi
Feb 21 07:10:04 raspberrypi CRON[26293]: pam_unix(cron:session): session closed for user pi
Feb 21 07:10:04 raspberrypi CRON[26294]: pam_unix(cron:session): session closed for user pi
Feb 21 07:10:05 raspberrypi CRON[26289]: pam_unix(cron:session): session closed for user pi
Feb 21 07:10:05 raspberrypi CRON[26290]: pam_unix(cron:session): session closed for user pi
Feb 21 07:10:06 raspberrypi CRON[26295]: pam_unix(cron:session): session closed for user pi
Feb 21 07:10:11 raspberrypi CRON[26296]: pam_unix(cron:session): session closed for user pi
Feb 21 07:10:12 raspberrypi CRON[26291]: pam_unix(cron:session): session closed for user pi
Feb 21 07:13:18 raspberrypi sudo[26460]: pi : TTY=pts/0 ; PWD=/home/pi ; USER=root ; COMMAND=/bin/journalctl -xn
Feb 21 07:13:18 raspberrypi sudo[26460]: pam_unix(sudo:session): session opened for user root by pi(uid=0)

似乎沒啥線索. 用 systemctl 指令重啟也是不成功 :

pi@raspberrypi:~ $ sudo systemctl restart mysql.service
Job for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.

檢視 /var/log/mysql/error.log 發現可能是資料庫分頁毀損 (page corruption), 可能需要重新安裝 :

pi@raspberrypi:~ $ cat /var/log/mysql/error.log
170221  6:50:43 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
170221  6:50:43 [Note] Plugin 'FEDERATED' is disabled.
170221  6:50:43 InnoDB: The InnoDB memory heap is disabled
170221  6:50:43 InnoDB: Mutexes and rw_locks use GCC atomic builtins
170221  6:50:43 InnoDB: Compressed tables use zlib 1.2.8
170221  6:50:43 InnoDB: Using Linux native AIO
170221  6:50:43 InnoDB: Initializing buffer pool, size = 128.0M
170221  6:50:43 InnoDB: Completed initialization of buffer pool
170221  6:50:43 InnoDB: highest supported file format is Barracuda.
InnoDB: Log scan progressed past the checkpoint lsn 1539448058
170221  6:50:43  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 1539464794
170221  6:50:44  InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents: 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
InnoDB: Apply batch completed
InnoDB: Database page corruption on disk or a failed   (資料庫毀損?)
InnoDB: file read of page 1622.
InnoDB: You may have to recover from a backup.   (要重裝系統?)
..... (很長的 page dump : 略) .....
InnoDB: End of page dump
170221  7:15:21  InnoDB: Page checksum 627908371, prior-to-4.0.14-form checksum 3948757627
InnoDB: stored checksum 3484663501, prior-to-4.0.14-form stored checksum 3948757627
InnoDB: Page lsn 0 20662285, low 4 bytes of lsn at page end 20662285
InnoDB: Page number (if stored to page already) 1622,
InnoDB: space id (if created with >= MySQL-4.1.1 and stored already) 0
InnoDB: Page may be an index page where index id is 3
InnoDB: (index "CLUST_IND" of table "SYS_INDEXES")
InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 1622.
InnoDB: You may have to recover from a backup.
InnoDB: It is also possible that your operating
InnoDB: system has corrupted its own file cache
InnoDB: and rebooting your computer removes the
InnoDB: error.
InnoDB: If the corrupt page is an index page
InnoDB: you can also try to fix the corruption
InnoDB: by dumping, dropping, and reimporting
InnoDB: the corrupt table. You can use CHECK
InnoDB: TABLE to scan your table for corruption.
InnoDB: about forcing recovery.
InnoDB: Ending processing because of a corrupt database page.
170221  7:15:21  InnoDB: Assertion failure in thread 3069522928 in file buf0buf.c line 3623
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
23:15:21 UTC - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.

key_buffer_size=16777216
read_buffer_size=131072
max_used_connections=0
max_threads=151
thread_count=0
connection_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 346093 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0 thread_stack 0x30000
information that should help you find out what is causing the crash.

我參考下面這篇試試看能否將 MySQL 系統救回來 :

# ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

pi@raspberrypi:~ $ sudo service mysql start
Job for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.
pi@raspberrypi:~ $ ps -A|grep mysql
pi@raspberrypi:~ $ sudo pkill mysql
pi@raspberrypi:~ $ sudo pkill mysqld
pi@raspberrypi:~ $ service mysql restart
Failed to restart mysql.service: Access denied
pi@raspberrypi:~ $ sudo service mysql restart
Job for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.
pi@raspberrypi:~ $ mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
pi@raspberrypi:~ $ systemctl status mysql.service
● mysql.service - LSB: Start and stop the mysql database server daemon
   Loaded: loaded (/etc/init.d/mysql)
   Active: failed (Result: exit-code) since Mon 2017-02-20 23:21:01 CST; 1min 31s ago
  Process: 3821 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)

仍然無濟於事, 看來只好將 MySQL 移除重新安裝了. 參考下面這篇 :

# How do I completely remove mysql-server on Debian?

pi@raspberrypi:~ $ dpkg -S /etc/mysql
mysql-server-5.5, mysql-common: /etc/mysql

先用 apt-get remove --purge 'mysql-.*' 指令將 MySQL 完全移除 :

pi@raspberrypi:/var/www/html $ sudo apt-get remove --purge 'mysql-.*'
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'mha4mysql-node' for regex 'mysql-.*'
Note, selecting 'libghc6-hsql-mysql-prof' for regex 'mysql-.*'
Note, selecting 'bacula-common-mysql-dbg' for regex 'mysql-.*'
Note, selecting 'lighttpd-mod-mysql-vhost' for regex 'mysql-.*'
Note, selecting 'virtual-mysql-client' for regex 'mysql-.*'
Note, selecting 'dpm-mysql-copyd' for regex 'mysql-.*'
Note, selecting 'mysql-mmm-agent' for regex 'mysql-.*'
Note, selecting 'libmysql-java' for regex 'mysql-.*'
Note, selecting 'virtual-mysql-server-core' for regex 'mysql-.*'
Note, selecting 'virtual-mysql-testsuite' for regex 'mysql-.*'
Note, selecting 'virtual-mysql-server' for regex 'mysql-.*'
Note, selecting 'libwtdbomysql-dev' for regex 'mysql-.*'
Note, selecting 'mysql-server-5.0' for regex 'mysql-.*'
Note, selecting 'mysql-server-5.1' for regex 'mysql-.*'
Note, selecting 'mysql-server-5.5' for regex 'mysql-.*'
Note, selecting 'mysql-server-5.6' for regex 'mysql-.*'
Note, selecting 'haskell-hsql-mysql-doc' for regex 'mysql-.*'
Note, selecting 'libdbd-mysql-5.1-perl' for regex 'mysql-.*'
Note, selecting 'voms-mysql-plugin-dbg' for regex 'mysql-.*'
Note, selecting 'mysql-navigator' for regex 'mysql-.*'
Note, selecting 'libmysql-ocaml-dev-ep3t6' for regex 'mysql-.*'
Note, selecting 'kexi-mysql-driver' for regex 'mysql-.*'
Note, selecting 'mysql-testsuite-5.5' for regex 'mysql-.*'
Note, selecting 'mysql-testsuite-5.6' for regex 'mysql-.*'
Note, selecting 'mysql-client-core-5.5' for regex 'mysql-.*'
Note, selecting 'mysql-client-core-5.6' for regex 'mysql-.*'
Note, selecting 'mysql-client' for regex 'mysql-.*'
Note, selecting 'libmysql-ocaml' for regex 'mysql-.*'
Note, selecting 'libdatetime-format-mysql-perl' for regex 'mysql-.*'
Note, selecting 'lua-dbi-mysql-dbg' for regex 'mysql-.*'
Note, selecting 'mysql-mmm-tools' for regex 'mysql-.*'
Note, selecting 'mysql-server' for regex 'mysql-.*'
Note, selecting 'mysql-proxy' for regex 'mysql-.*'
Note, selecting 'lua-dbi-mysql-dev' for regex 'mysql-.*'
Note, selecting 'mha4mysql-master' for regex 'mysql-.*'
Note, selecting 'dpm-mysql-srmv22' for regex 'mysql-.*'
Note, selecting 'mha4mysql-manager' for regex 'mysql-.*'
Note, selecting 'libcrypt-mysql-perl' for regex 'mysql-.*'
Note, selecting 'lua5.1-dbi-mysql-dev' for regex 'mysql-.*'
Note, selecting 'lua5.2-sql-mysql-dev' for regex 'mysql-.*'
Note, selecting 'libghc-hsql-mysql-prof' for regex 'mysql-.*'
Note, selecting 'libtime-piece-mysql-perl' for regex 'mysql-.*'
Note, selecting 'gsql-mysql-engine' for regex 'mysql-.*'
Note, selecting 'libdbd-mysql-perl' for regex 'mysql-.*'
Note, selecting 'libnss-mysql-bg' for regex 'mysql-.*'
Note, selecting 'libmysql-diff-perl' for regex 'mysql-.*'
Note, selecting 'libkaya-mysql-dev' for regex 'mysql-.*'
Note, selecting 'libghc-hsql-mysql-dev-1.8.2-8c662' for regex 'mysql-.*'
Note, selecting 'bacula-sd-mysql-dbg' for regex 'mysql-.*'
Note, selecting 'bacula-director-mysql-dbg' for regex 'mysql-.*'
Note, selecting 'mysql-mmm-monitor' for regex 'mysql-.*'
Note, selecting 'libghc6-hsql-mysql-dev' for regex 'mysql-.*'
Note, selecting 'mysql-source-5.5' for regex 'mysql-.*'
Note, selecting 'mysql-workbench' for regex 'mysql-.*'
Note, selecting 'libmysql-ocaml-ep3t6' for regex 'mysql-.*'
Note, selecting 'mysql-client-5.0' for regex 'mysql-.*'
Note, selecting 'mysql-client-5.1' for regex 'mysql-.*'
Note, selecting 'mysql-client-5.5' for regex 'mysql-.*'
Note, selecting 'mysql-client-5.6' for regex 'mysql-.*'
Note, selecting 'libclass-dbi-mysql-perl' for regex 'mysql-.*'
Note, selecting 'mysql-testsuite' for regex 'mysql-.*'
Note, selecting 'libghc-hsql-mysql-dev' for regex 'mysql-.*'
Note, selecting 'virtual-mysql-client-core' for regex 'mysql-.*'
Note, selecting 'pinba-engine-mysql-5.5' for regex 'mysql-.*'
Note, selecting 'mysql-common' for regex 'mysql-.*'
Note, selecting 'handlersocket-mysql-5.1' for regex 'mysql-.*'
Note, selecting 'handlersocket-mysql-5.5' for regex 'mysql-.*'
Note, selecting 'mysql-server-core-5.0' for regex 'mysql-.*'
Note, selecting 'mysql-server-core-5.1' for regex 'mysql-.*'
Note, selecting 'mysql-server-core-5.5' for regex 'mysql-.*'
Note, selecting 'mysql-server-core-5.6' for regex 'mysql-.*'
Note, selecting 'libreoffice-mysql-connector' for regex 'mysql-.*'
Note, selecting 'dpm-mysql-nameserver' for regex 'mysql-.*'
Note, selecting 'libghc6-hsql-mysql-doc' for regex 'mysql-.*'
Note, selecting 'mysql-server-core' for regex 'mysql-.*'
Note, selecting 'voms-mysql-plugin' for regex 'mysql-.*'
Note, selecting 'monodoc-mysql-manual' for regex 'mysql-.*'
Note, selecting 'lua-sql-mysql-dev' for regex 'mysql-.*'
Note, selecting 'mysql-utilities' for regex 'mysql-.*'
Note, selecting 'libghc-hsql-mysql-doc' for regex 'mysql-.*'
Note, selecting 'dpm-mysql-srmv1' for regex 'mysql-.*'
Note, selecting 'dpm-mysql-srmv2' for regex 'mysql-.*'
Note, selecting 'libghc-hsql-mysql-prof-1.8.2-8c662' for regex 'mysql-.*'
Note, selecting 'mysql-workbench-data' for regex 'mysql-.*'
Note, selecting 'lua5.1-sql-mysql-dev' for regex 'mysql-.*'
Note, selecting 'libmysql-ocaml-dev' for regex 'mysql-.*'
Note, selecting 'mysql-mmm-common' for regex 'mysql-.*'
Note, selecting 'libmysql-cil-dev' for regex 'mysql-.*'
Note, selecting 'mysql-server-core-5.5' instead of 'mysql-server-core'
Note, selecting 'dpm-copy-server-mysql' instead of 'dpm-mysql-copyd'
Note, selecting 'dpm-name-server-mysql' instead of 'dpm-mysql-nameserver'
Note, selecting 'dpm-srm-server-mysql' instead of 'dpm-mysql-srmv1'
Note, selecting 'dpm-srm-server-mysql' instead of 'dpm-mysql-srmv2'
Note, selecting 'dpm-srm-server-mysql' instead of 'dpm-mysql-srmv22'
Package 'handlersocket-mysql-5.1' is not installed, so not removed
Note, selecting 'libghc-hsql-mysql-dev' instead of 'libghc-hsql-mysql-dev-1.8.2-8c662'
Note, selecting 'libghc-hsql-mysql-prof' instead of 'libghc-hsql-mysql-prof-1.8.2-8c662'
Note, selecting 'libmysql-ocaml' instead of 'libmysql-ocaml-ep3t6'
Note, selecting 'libmysql-ocaml-dev' instead of 'libmysql-ocaml-dev-ep3t6'
Note, selecting 'lua-dbi-mysql-dev' instead of 'lua5.1-dbi-mysql-dev'
Note, selecting 'lua-sql-mysql-dev' instead of 'lua5.1-sql-mysql-dev'
Note, selecting 'lua-sql-mysql-dev' instead of 'lua5.2-sql-mysql-dev'
Package 'libdbd-mysql-5.1-perl' is not installed, so not removed
Package 'mysql-server-5.1' is not installed, so not removed
Package 'mysql-client-core-5.5' is not installed, so not removed
Package 'mysql-client-core-5.6' is not installed, so not removed
Package 'mysql-client-5.6' is not installed, so not removed
Package 'mysql-server-core-5.6' is not installed, so not removed
Package 'mysql-server-5.6' is not installed, so not removed
Package 'mysql-testsuite-5.6' is not installed, so not removed
Package 'mha4mysql-master' is not installed, so not removed
Package 'mysql-client-5.0' is not installed, so not removed
Package 'mysql-client-5.1' is not installed, so not removed
Package 'mysql-server-core-5.1' is not installed, so not removed
Package 'mysql-server-5.0' is not installed, so not removed
Package 'mysql-server-core-5.0' is not installed, so not removed
Package 'bacula-common-mysql-dbg' is not installed, so not removed
Package 'bacula-director-mysql-dbg' is not installed, so not removed
Package 'bacula-sd-mysql-dbg' is not installed, so not removed
Package 'gsql-mysql-engine' is not installed, so not removed
Package 'handlersocket-mysql-5.5' is not installed, so not removed
Package 'haskell-hsql-mysql-doc' is not installed, so not removed
Package 'kexi-mysql-driver' is not installed, so not removed
Package 'libclass-dbi-mysql-perl' is not installed, so not removed
Package 'libcrypt-mysql-perl' is not installed, so not removed
Package 'libdatetime-format-mysql-perl' is not installed, so not removed
Package 'libghc-hsql-mysql-dev' is not installed, so not removed
Package 'libghc-hsql-mysql-doc' is not installed, so not removed
Package 'libghc-hsql-mysql-prof' is not installed, so not removed
Package 'libghc6-hsql-mysql-dev' is not installed, so not removed
Package 'libghc6-hsql-mysql-doc' is not installed, so not removed
Package 'libghc6-hsql-mysql-prof' is not installed, so not removed
Package 'libkaya-mysql-dev' is not installed, so not removed
Package 'libmysql-cil-dev' is not installed, so not removed
Package 'libmysql-diff-perl' is not installed, so not removed
Package 'libmysql-java' is not installed, so not removed
Package 'libmysql-ocaml' is not installed, so not removed
Package 'libmysql-ocaml-dev' is not installed, so not removed
Package 'libnss-mysql-bg' is not installed, so not removed
Package 'libtime-piece-mysql-perl' is not installed, so not removed
Package 'libwtdbomysql-dev' is not installed, so not removed
Package 'lighttpd-mod-mysql-vhost' is not installed, so not removed
Package 'lua-dbi-mysql-dbg' is not installed, so not removed
Package 'lua-dbi-mysql-dev' is not installed, so not removed
Package 'lua-sql-mysql-dev' is not installed, so not removed
Package 'mha4mysql-manager' is not installed, so not removed
Package 'mha4mysql-node' is not installed, so not removed
Package 'monodoc-mysql-manual' is not installed, so not removed
Package 'mysql-mmm-agent' is not installed, so not removed
Package 'mysql-mmm-common' is not installed, so not removed
Package 'mysql-mmm-monitor' is not installed, so not removed
Package 'mysql-mmm-tools' is not installed, so not removed
Package 'mysql-navigator' is not installed, so not removed
Package 'mysql-proxy' is not installed, so not removed
Package 'mysql-source-5.5' is not installed, so not removed
Package 'mysql-testsuite' is not installed, so not removed
Package 'mysql-testsuite-5.5' is not installed, so not removed
Package 'mysql-utilities' is not installed, so not removed
Package 'mysql-workbench' is not installed, so not removed
Package 'mysql-workbench-data' is not installed, so not removed
Package 'pinba-engine-mysql-5.5' is not installed, so not removed
Package 'voms-mysql-plugin' is not installed, so not removed
Package 'voms-mysql-plugin-dbg' is not installed, so not removed
Package 'libreoffice-mysql-connector' is not installed, so not removed
The following packages were automatically installed and are no longer required:
  libaio1 libdbi-perl libhtml-template-perl libterm-readkey-perl
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  libdbd-mysql-perl* libmailutils4* libmysqlclient18* mailutils* mysql-client* mysql-client-5.5* mysql-common* mysql-server* mysql-server-5.5*
  mysql-server-core-5.5* php5-mysql*
0 upgraded, 0 newly installed, 11 to remove and 17 not upgraded.
After this operation, 90.7 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 131585 files and directories currently installed.)
Removing mysql-server (5.5.54-0+deb8u1) ...
Removing mysql-server-5.5 (5.5.54-0+deb8u1) ...
Purging configuration files for mysql-server-5.5 (5.5.54-0+deb8u1) ...
Removing mysql-client (5.5.54-0+deb8u1) ...
Removing mysql-client-5.5 (5.5.54-0+deb8u1) ...
Removing libdbd-mysql-perl (4.028-2+deb8u2) ...
Removing mailutils (1:2.99.98-2) ...
update-alternatives: using /usr/bin/bsd-from to provide /usr/bin/from (from) in auto mode
Removing libmailutils4:armhf (1:2.99.98-2) ...
Purging configuration files for libmailutils4:armhf (1:2.99.98-2) ...
Removing php5-mysql (5.6.29+dfsg-0+deb8u1) ...
php5_invoke prerm: Disable module mysql for cli SAPI
php5_invoke prerm: Disable module mysql for apache2 SAPI
php5_invoke prerm: Disable module mysqli for cli SAPI
php5_invoke prerm: Disable module mysqli for apache2 SAPI
php5_invoke prerm: Disable module pdo_mysql for cli SAPI
php5_invoke prerm: Disable module pdo_mysql for apache2 SAPI
Purging configuration files for php5-mysql (5.6.29+dfsg-0+deb8u1) ...
Removing libmysqlclient18:armhf (5.5.54-0+deb8u1) ...
Purging configuration files for libmysqlclient18:armhf (5.5.54-0+deb8u1) ...
Removing mysql-common (5.5.54-0+deb8u1) ...
Purging configuration files for mysql-common (5.5.54-0+deb8u1) ...
dpkg: warning: while removing mysql-common, directory '/etc/mysql' not empty so not removed
Removing mysql-server-core-5.5 (5.5.54-0+deb8u1) ...
Processing triggers for man-db (2.7.0.2-5) ...
Processing triggers for libc-bin (2.19-18+deb8u7) ...
Processing triggers for libapache2-mod-php5 (5.6.29+dfsg-0+deb8u1) ...

移除完畢後重新安裝 MySQL 伺服器 :

pi@raspberrypi:/var/www/html $ sudo apt-get install mysql-server mysql-client php5-mysql
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  guile-2.0-libs libgc1c2 libgsasl7 libkyotocabinet16 libntlm0 libunistring0 mailutils-common
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  libdbd-mysql-perl libmysqlclient18 mysql-client-5.5 mysql-common mysql-server-5.5 mysql-server-core-5.5
Suggested packages:
  mailx tinyca
The following NEW packages will be installed:
  libdbd-mysql-perl libmysqlclient18 mysql-client mysql-client-5.5 mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php5-mysql
0 upgraded, 9 newly installed, 0 to remove and 17 not upgraded.
Need to get 0 B/7,542 kB of archives.
After this operation, 87.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 131205 files and directories currently installed.)
Preparing to unpack .../mysql-common_5.5.54-0+deb8u1_all.deb ...
Unpacking mysql-common (5.5.54-0+deb8u1) ...
Selecting previously unselected package libmysqlclient18:armhf.
Preparing to unpack .../libmysqlclient18_5.5.54-0+deb8u1_armhf.deb ...
Unpacking libmysqlclient18:armhf (5.5.54-0+deb8u1) ...
Selecting previously unselected package libdbd-mysql-perl.
Preparing to unpack .../libdbd-mysql-perl_4.028-2+deb8u2_armhf.deb ...
Unpacking libdbd-mysql-perl (4.028-2+deb8u2) ...
Selecting previously unselected package mysql-client-5.5.
Preparing to unpack .../mysql-client-5.5_5.5.54-0+deb8u1_armhf.deb ...
Unpacking mysql-client-5.5 (5.5.54-0+deb8u1) ...
Selecting previously unselected package mysql-server-core-5.5.
Preparing to unpack .../mysql-server-core-5.5_5.5.54-0+deb8u1_armhf.deb ...
Unpacking mysql-server-core-5.5 (5.5.54-0+deb8u1) ...
Processing triggers for man-db (2.7.0.2-5) ...
Setting up mysql-common (5.5.54-0+deb8u1) ...
Selecting previously unselected package mysql-server-5.5.
(Reading database ... 131397 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.5_5.5.54-0+deb8u1_armhf.deb ...
Unpacking mysql-server-5.5 (5.5.54-0+deb8u1) ...
Selecting previously unselected package mysql-client.
Preparing to unpack .../mysql-client_5.5.54-0+deb8u1_all.deb ...
Unpacking mysql-client (5.5.54-0+deb8u1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.5.54-0+deb8u1_all.deb ...
Unpacking mysql-server (5.5.54-0+deb8u1) ...
Selecting previously unselected package php5-mysql.
Preparing to unpack .../php5-mysql_5.6.29+dfsg-0+deb8u1_armhf.deb ...
Unpacking php5-mysql (5.6.29+dfsg-0+deb8u1) ...
Processing triggers for man-db (2.7.0.2-5) ...
Processing triggers for systemd (215-17+deb8u6) ...
Processing triggers for libapache2-mod-php5 (5.6.29+dfsg-0+deb8u1) ...
Setting up libmysqlclient18:armhf (5.5.54-0+deb8u1) ...
Setting up libdbd-mysql-perl (4.028-2+deb8u2) ...
Setting up mysql-client-5.5 (5.5.54-0+deb8u1) ...
Setting up mysql-server-core-5.5 (5.5.54-0+deb8u1) ...
Setting up mysql-server-5.5 (5.5.54-0+deb8u1) ...
170222 20:55:27 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
170222 20:55:27 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
170222 20:55:27 [Note] /usr/sbin/mysqld (mysqld 5.5.54-0+deb8u1) starting as process 30672 ...
insserv: warning: script 'K01vncboot' missing LSB tags and overrides
insserv: warning: script 'vncboot' missing LSB tags and overrides
Job for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up mysql-client (5.5.54-0+deb8u1) ...
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.5; however:
  Package mysql-server-5.5 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Setting up php5-mysql (5.6.29+dfsg-0+deb8u1) ...

Creating config file /etc/php5/mods-available/mysql.ini with new version
php5_invoke: Enable module mysql for cli SAPI
php5_invoke: Enable module mysql for apache2 SAPI

Creating config file /etc/php5/mods-available/mysqli.ini with new version
php5_invoke: Enable module mysqli for cli SAPI
php5_invoke: Enable module mysqli for apache2 SAPI

Creating config file /etc/php5/mods-available/pdo_mysql.ini with new version
php5_invoke: Enable module pdo_mysql for cli SAPI
php5_invoke: Enable module pdo_mysql for apache2 SAPI
Processing triggers for libc-bin (2.19-18+deb8u7) ...
Processing triggers for systemd (215-17+deb8u6) ...
Processing triggers for libapache2-mod-php5 (5.6.29+dfsg-0+deb8u1) ...
Errors were encountered while processing:
 mysql-server-5.5
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

如上黃色凸顯部分所示, 重新安裝時出現錯誤, 仍然是無法啟動 MySQL 服務, 所以重新安裝完成後仍然無法登入 phpMyAdmin. 因為對 Linux 不熟, 看來只有重新安裝系統了.

參考 :

Can't start mysql service [closed]  (無用)
How to remove MySQL completely with config and library files?
# The MySQL Command-Line Tool

沒有留言 :