cara menginstal ulang mysql?


38

Pembaruan perangkat lunak rusak, antara lain, mysql dan saya belum bisa mendapatkannya kembali.

Penyebab yang dicurigai: Saya memiliki disk boot hampir penuh; pemutakhiran mengisi disk sebelum menyelesaikan dan dengan demikian membuat semuanya berantakan. Saya telah memberikan sistem lebih banyak disk dan pindah / var ke partisi sendiri. Saya masih gagal mencoba untuk menghidupkan kembali mysql.

Di bawah ini adalah apa yang saya coba sejauh ini (semuanya sebagai root). Pertama, mysql tidak memulai (443). Upaya untuk memperbaiki (444, 445) gagal. Upaya untuk menghapus mysql dan (?) Apparmor gagal (446, 7, 8). Upaya yang lebih energik untuk menghapus mysql tampaknya berhasil (449) dan kesalahan sebelumnya tidak lagi terlihat (450, 1, 2). Mysql tidak dapat dikonfigurasi ulang karena tidak ada lagi di sana (453) tetapi berusaha menginstalnya mengembalikan pesan kesalahan lama dan kami kembali ke titik awal (454).

Saya juga memeriksa pertanyaan ini (meskipun dalam kasus saya itu tidak rusak karena upgrade ke 12,04: itu sudah bekerja pada 12,10) Memperbaiki paket myslq-server yang rusak setelah upgrade ke 12,04 dan mencoba saran di sana (458, 461, 462) tidak berhasil.

Apa lagi yang harus saya lakukan?

Ini adalah 3.5.0-25-25 generik # 39-Ubuntu SMP Senin 25 Feb 18:26:58 UTC 2013 x86_64 x86_64 x86_64 GNU / Linux

    443  service mysql start
         start: Job failed to start

    444  dpkg-reconfigure mysql-server-5.5
         /usr/sbin/dpkg-reconfigure: mysql-server-5.5
         is broken or not fully installed

    445  apt-get -f install
         ...
         Setting up mysql-server-5.5 (5.5.29-0ubuntu0.12.10.1) ...
         start: Job failed to start
         invoke-rc.d: initscript mysql, action "start" failed.
         dpkg: error processing 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 mysql-server (--configure):
         dependency problems - leaving unconfigured
         No apport report written because the error message
         indicates its a followup error from a previous failure.
         Errors were encountered while processing:
           mysql-server-5.5
           mysql-server
         E: Sub-process /usr/bin/dpkg returned an error code (1)

    446  apt-get remove mysql-server
         ...
         Removing mysql-server ...
         Setting up mysql-server-5.5 (5.5.29-0ubuntu0.12.10.1) ...
         start: Job failed to start
         invoke-rc.d: initscript mysql, action "start" failed.
         dpkg: error processing mysql-server-5.5 (--configure):
         subprocess installed post-installation script
         returned error exit status 1
         No apport report written because MaxReports is reached already
         Errors were encountered while processing:
           mysql-server-5.5
         E: Sub-process /usr/bin/dpkg returned an error code (1)


    447  apt-get remove apparmor
         ...
         Package 'apparmor' is not installed, so not removed
         0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
         1 not fully installed or removed.
         After this operation, 0 B of additional disk space will be used. 
         Setting up mysql-server-5.5 (5.5.29-0ubuntu0.12.10.1) ...
         start: Job failed to start
         invoke-rc.d: initscript mysql, action "start" failed.
         dpkg: error processing mysql-server-5.5 (--configure):
         subprocess installed post-installation script
         returned error exit status 1
         Errors were encountered while processing:
           mysql-server-5.5
         E: Sub-process /usr/bin/dpkg returned an error code (1)


    448  apt-get remove mysql-server
         Reading package lists... Done
         Building dependency tree       
         Reading state information... Done
         Package 'mysql-server' is not installed, so not removed
         0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
         1 not fully installed or removed.
         After this operation, 0 B of additional disk space will be used.
         Setting up mysql-server-5.5 (5.5.29-0ubuntu0.12.10.1) ...
         start: Job failed to start
         invoke-rc.d: initscript mysql, action "start" failed.
         dpkg: error processing mysql-server-5.5 (--configure):
         subprocess installed post-installation script
         returned error exit status 1
         Errors were encountered while processing:
           mysql-server-5.5
         E: Sub-process /usr/bin/dpkg returned an error code (1)

    449  dpkg -r mysql-server-5.5
         (Reading database ... 322156 files and directories
         currently installed.)
         Removing mysql-server-5.5 ...
         Processing triggers for man-db ...
         Processing triggers for ureadahead ...

    450  apt-get remove mysql-server
         Reading package lists... Done
         Building dependency tree        
         Reading state information... Done
         Package 'mysql-server' is not installed, so not removed
         0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

    451  apt-get remove apparmor
         Reading package lists... Done
         Building dependency tree       
         Reading state information... Done
         Package 'apparmor' is not installed, so not removed
         0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

    452  apt-get -f install
         Reading package lists... Done
         Building dependency tree       
         Reading state information... Done
         0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

    453  dpkg-reconfigure mysql-server-5.5
         /usr/sbin/dpkg-reconfigure: mysql-server-5.5 is broken
         or not fully installed

    454  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
         Suggested packages:
           tinyca mailx
         The following NEW packages will be installed:
           mysql-server mysql-server-5.5
         0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
         Need to get 0 B/8,851 kB of archives.
         After this operation, 32.8 MB of additional disk space
         will be used.
         Do you want to continue [Y/n]? 
         Preconfiguring packages ...
         Selecting previously unselected package mysql-server-5.5.
         (Reading database ... 322081 files and directories
         currently installed.)
         Unpacking mysql-server-5.5 (from 
         .../mysql-server-5.5_5.5.29-0ubuntu0.12.10.1_amd64.deb) ...
         Selecting previously unselected package mysql-server.
         Unpacking mysql-server (from 
         .../mysql-server_5.5.29-0ubuntu0.12.10.1_all.deb) ...
         Processing triggers for ureadahead ...
         Processing triggers for man-db ...
         Setting up mysql-server-5.5 (5.5.29-0ubuntu0.12.10.1) ...
         start: Job failed to start
         invoke-rc.d: initscript mysql, action "start" failed.
         dpkg: error processing 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 mysql-server (--configure):
         dependency problems - leaving unconfigured
         No apport report written because the error message
         indicates its a followup error from a previous failure.
         Errors were encountered while processing:
           mysql-server-5.5
           mysql-server
         E: Sub-process /usr/bin/dpkg returned an error code (1)


    458  apt-get remove --purge mysql-server
         Reading package lists... Done
         Building dependency tree       
         Reading state information... Done
         The following packages will be REMOVED:
           mysql-server*
         0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
         2 not fully installed or removed.
         After this operation, 116 kB disk space will be freed.
         Do you want to continue [Y/n]? 
         (Reading database ... 322159 files and directories
         currently installed.)
         Removing mysql-server ...
         Setting up mysql-server-5.5 (5.5.29-0ubuntu0.12.10.1) ...
         start: Job failed to start
         invoke-rc.d: initscript mysql, action "start" failed.
         dpkg: error processing mysql-server-5.5 (--configure):
         subprocess installed post-installation script
         returned error exit status 1
         Errors were encountered while processing:
           mysql-server-5.5
         E: Sub-process /usr/bin/dpkg returned an error code (1)

    461  touch /etc/apparmor.d/local/usr.sbin.mysqld
         (no output)

    462  service mysql start
         start: Job failed to start

Jawaban:


80

Pertama, hapus MySQL:

sudo apt purge mysql-server mysql-client mysql-common
sudo apt autoremove
sudo mv -iv /var/lib/mysql /var/tmp/mysql-backup
sudo rm -rf /var/lib/mysql*

Kemudian pasang kembali:

sudo apt update
sudo apt install mysql-server
sudo mysql_install_db
sudo /usr/bin/mysql_secure_installation

1
penjelasan sempurna!
Postadelmaga

Saya pikir itu layak disebutkan yang --purgebelum tentu apa yang diinginkan, karena akan menghapus file konfigurasi juga. Khusus untuk mysql, saya ingin tahu apakah itu akan menghapus dbs juga?
user50849

10
Untuk menghapus konfigurasi dan basis data, Anda harus menghapus /etc/mysqldan /var/lib/mysql.
Anne van Rossum

2
Anda harus menghentikan layanan mysql untuk menghapus mysql-server
Viktor

6
2017-05-20 15:12:01 [PERINGATAN] mysql_install_db sudah usang. Silakan pertimbangkan untuk beralih ke mysqld --initialize
Flaudre

12

Di Ubuntu 16.04 cara untuk memperbaikinya dalam kasus saya adalah ( harap cadangkan DBs terlebih dahulu, basis data akan hilang ):

sudo apt remove --purge mysql-server mysql-client mysql-common
sudo apt autoremove
sudo mv -iv /var/lib/mysql /var/tmp/mysql-backup
sudo rm -rf /var/lib/mysql*
sudo apt install mysql-server

(Entah bagaimana, panggilan saya sebelumnya ke apt purge mysql-servertampaknya tidak berhasil. Saya pikir apt purge fooitu setara dengan apt remove --purge foo...)


Ini menghapus semua basis data. Diperlukan cadangan jika ada data yang penting.
flickerfly

8

Saya mendapatkan kesalahan yang sama persis dan mencoba sebagian besar langkah yang Anda lakukan, dengan hasil yang sama. Yang berikut ini akhirnya berhasil untuk saya.

apt-get purge mysql-server mysql-client mysql-common mysql-client-5.5 mysql-server-5.5

Setelah itu, mysql diinstal secara normal.


1

Saya tidak yakin apa masalahnya bagi saya, tetapi solusi lain tidak berhasil, itu terus memberikan kesalahan. Saya mencoba ini apt-get purge mysql-*, lalu autoremovedan autoclean. Setelah instalasi itu baik-baik saja.

**

Pastikan untuk membuat cadangan basis data Anda, perintah di atas juga dapat menghapusnya

**


0

Jika Anda hanya berlari

sudo apt-get update
sudo apt-get install mysql-server

itu akan memperbarui mysql dan ini memperbaiki masalah yang saya miliki setelah memperbarui ke 16,04 lts.

Atau lari saja

sudo apt-get install lamp-server^

untuk memperbarui semua paket server.


0

Untuk versi MySQL 5.7 saya menghapus MySQL seperti yang dijelaskan sebelumnya:

sudo apt purge mysql-server mysql-client mysql-common
sudo apt autoremove
sudo rm -rf /var/lib/mysql*

Dan memasangnya dengan bantuan:

sudo apt-get update
sudo apt-get install mysql-server
mysql_secure_installation

Untuk menguji apakah semuanya berfungsi:

systemctl status mysql.service

sumber


-5

Instal phpMyAdmin dari repositori Ubuntu default. Lalu lari:

dpkg --configure mysql-server-5.5
apt-get purge mysql-server mysql-client mysql-common mysql-client-5.5 mysql-server-5.5
apt-get autoremove
apt-get autoclean
apt-get update
apt-get install  mysql-server
service mysql restart

5
Mengapa menginstal phpMyAdmin ? Itu sama sekali tidak perlu.
Lucio
Dengan menggunakan situs kami, Anda mengakui telah membaca dan memahami Kebijakan Cookie dan Kebijakan Privasi kami.
Licensed under cc by-sa 3.0 with attribution required.