Pemrograman

Bahasa

Framework

Peralatan

Info

Solusi Masalah Dependensi Server MySQL di Ubuntu

– 24 April 2016
Gara-gara upgrade versi server MySQL tadi malam, servernya malah error. Awalnya saya menggunakan MySQL versi 5.5, kemudian ditingkatkan (upgrade) ke versi 5.6.
$ mysql -u root -p  
ERROR 2002 (HY000): Can't connect to local MySQL server through socket    '/var/run/mysqld/mysqld.sock' (2)
Kemudian saya mencoba menghapus mysql-server dan meninginstal lagi (instal ulang).
sudo apt-get remove mysql-server
sudo apt-get install mysql-server
Malah dapat error dependensi:
$ sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  mysql-server-5.5 mysql-server-core-5.5
Suggested packages:
  tinyca mailx
The following NEW packages will be installed:
  mysql-server mysql-server-5.5 mysql-server-core-5.5
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/5.144 kB of archives.
After this operation, 53,2 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
Selecting previously unselected package mysql-server-core-5.5.
(Reading database ... 272846 files and directories currently installed.)
Preparing to unpack .../mysql-server-core-5.5_5.5.49-0ubuntu0.14.04.1_amd64.deb ...
Unpacking mysql-server-core-5.5 (5.5.49-0ubuntu0.14.04.1) ...
Selecting previously unselected package mysql-server-5.5.
Preparing to unpack .../mysql-server-5.5_5.5.49-0ubuntu0.14.04.1_amd64.deb ...
Unpacking mysql-server-5.5 (5.5.49-0ubuntu0.14.04.1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.5.49-0ubuntu0.14.04.1_all.deb ...
Unpacking mysql-server (5.5.49-0ubuntu0.14.04.1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for ureadahead (0.100.0-16) ...
Setting up mysql-server-core-5.5 (5.5.49-0ubuntu0.14.04.1) ...
Setting up mysql-server-5.5 (5.5.49-0ubuntu0.14.04.1) ...
160424 14:50:11 [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.
160424 14:50:11 [Note] /usr/sbin/mysqld (mysqld 5.5.49-0ubuntu0.14.04.1) starting as process 12092 ...
start: Job failed to start
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
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
Processing triggers for ureadahead (0.100.0-16) ...
No apport report written because the error message indicates its a followup error from a previous failure.
Beberapa solusi sudah dilakukan, tapi masih belum juga bisa. Solusi terakhir yang saya temikan di Stackoverflow sangat ampuh. Solusi terakhir ini membersihkan semuanya: database, konfigurasi, user, paket-paket MySQL dll. Jangan coba-coba solusi ini, kalau anda belum yakin kehilangan semua hal yang berkaitan dengan MySQL. Berikut ini perintah-perintah ajaibnya.
$ sudo apt-get --yes autoremove --purge mysql-server-5.5

$ sudo apt-get --yes autoremove --purge mysql-client-5.5

$ sudo apt-get --yes autoremove --purge mysql-common

$ sudo rm -rf /var/lib/mysql /etc/mysql ~/.mysql



$ sudo deluser mysql

$ sudo apt-get autoclean

$ sudo apt-get update && sudo apt-get upgrade

$ sudo apt-get install mysql-server-5.5 mysql-client-5.5
Server MySQL yang ada di komputer saya pun kembali normal. Tetapi, semua databasenya hilang. Untunglah dulu sudah pernah membuat cadangan (back-up).