Ошибка при установке mysql на ubuntu server

Reposting my answer to a similar question here. I was able to resolve this issue on Ubuntu 22.04 using arief21’s solution to a similar problem on 20.04, which itself was copied from here.

Overview

It seems that the problem comes from some partial initialization remaining in the filesystem from the first, failed installation. So the solution is basically to make sure to clear out everything that was added or modified during the failed install attempts.

I didn’t have time to dive much deeper, so I don’t know precisely which files are to blame, but if anyone can offer more insight, please comment below for future readers who need a more delicate solution.

Purge Relevant Packages

  • Make sure MySQL is not running:
sudo systemctl stop mysql
  • Then purge all of the MySQL packages:
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
  • Then delete all of the MySQL files:
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql
  • Finally clean all packages that are not needed:
sudo apt autoremove
sudo apt autoclean
  • And it never hurts to do a reboot before moving on
sudo reboot

Now with any lingering configuration cruft culled, you should be able to run the install command again.

MySQL Apt Package Notes

I also read here that some people are experiencing problems with installation of the mysql-server on Jammy, recommending instead to install the specific mysql-server-8.0 and mysql-server-core-8.0 packages. Not 100% sure of the truth of this, as I didn’t try the mysql-server metapackage again after a full purge.

sudo apt install mysql-server-core-8.0 mysql-server-8.0

Hope this helps!

При попытке установки mysql-server на Ubuntu выходит ошибка, помогите разобраться.

dpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 package post-installation script subprocess returned
error exit status 2
Setting up libcgi-pm-perl (4.46-1) ...
Setting up Libhtml-template-perl (2.97-1) ...
dpkg: dependency problems prevent configuration of mysql-server:
mysql server depends on mysql-server-8.0;however;
Package mysql-server-8.0 is not configured yet.

dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
Setting up libcgi-fast-perl (1:2.15-1) ...
No apport report written because the error message indicates its a followup erro
r from a previous failure.
Processing triggers for systemd (245.4-4ubuntu3.15)

Processing triggers for man-db (2.9.1-1) ...

Not Building database; man-db/auto-update is not 'True'.
Processing triggers for libc-bin (2.31-Oubuntu9.2) ...

Errors were encountered while processing:
mysql-server-8.0
mysql-server

E: Sub-process /usr/bin/dpkg returned an error code (1)

Перечитал множество разнообразных статей по этому поводу, но того, чтобы мне помогло, так и не нашёл.

Добрый день! Прошу помощи.
Имеется сервер с LMS Moodle на базе ubuntu 20.04 + Mysql 8 + apache.
С какого-то времени начались проблемы с установщиком, когда при попытке что-либо поставить выходила такая ошибка

^Cdpkg: ошибка при обработке пакета mysql-server-8.0 (—configure):
 installed mysql-server-8.0 package post-installation script subprocess was interrupted

, после чего сайт с LMS переставал работать с ошибкой базы данных. После перезагрузки сайт восстанавливался, поэтому проблему оставила на «потом». Так прошел год  :)

На сегодняшний день я приняла решение (возможно, неправильное, но все же) переустановить mysql и заодно обновить сервер. В итоге не получилось поставить mysql. Помогите. Ниже привожу свои действия.

1) Бэкап базы и конфигурационных файлов

Скопировала конфиги и базу в домашнюю директорию с сохранением параметров

cp -avt /home/sadmin/mysql_back /var/lib/mysql /etc/mysql/

2) Удаление mysql

2.1. Остановила сервис mysql

service mysql stop
2.2. Поискала установленные пакеты, которые относятся к mysql, чтоб знать какие пакеты удалить

apt search mysql-server
и

apt search mysql-client
2.3. Чистка директории мускула с конфигами 

эрэм эрэф /etc/mysql/
и логов

эрэм эрэф /var/log/mysql2.4. удалила пакеты, которые показал мне выхлоп команды из п. 2.2.

apt purge default-mysql-client default-mysql-client-core mysql-client mysql-client-8.0 mysql-client-core-8.0
Первый упс:

2.5. Повторяю пункт 2.4. Удаление проходит без траблов.
2.6.

apt autoremove
3) Обновление системы

apt-get update

apt-get upgrade
Второй упс

4) Установка mysql

apt install mysql-server mysql-client
Сейчас на 90% установка закончена, но не завершается, висит

Заглянула в /var/log/mysql/error.log и пребываю в растерянности:

Процесс apt до сих пор висит на установке mysql и я уже не знаю, что делать.


UPD. Перезагрузила сервер, удалила файлы в /var/lib/mysql-files
и отредактировала файл /var/lib/dpkg/info/mysql-server-8.0.postinst, проставив  # перед строчкой

echo "ALTER USER 'root'@'localhost' IDENTIFIED WITH 'auth_socket';" >> "$initfile"
Запустила

dpkg --configure -a и получила

Сейчас думаю заменить конфиги из первого пункта конфигами бэкапа. И толком не знаю вообще, правильно ли поступаю :(


Пользователь добавил сообщение 06 Июля 2021, 16:10:16:


Откатила сервер до удаления mySQL, чтобы не совершать лишних ошибок, наверняка, я что-то делала не так
Вот выхлоп. Сайт работает, а ошибка сохраняется.

Критично ли это? Стоит ли заблокировать обновления для этого пакета? Или есть способы исправить ситуацию?

I installed mariadb-server before installing mysql-server (which I wasn’t supposed to do), so I purged mariadb* and removed it from the repos. However, I can’t install mysql-server.

After sudo apt-get install mysql-server, I get:

Setting up mysql-server-5.7 (5.7.19-0ubuntu0.16.04.1) ...
invoke-rc.d: could not determine current runlevel
 * Stopping MySQL database server mysqld                                                                                                                                     [ OK ] update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
invoke-rc.d: could not determine current runlevel
invoke-rc.d: could not determine current runlevel
 * Stopping MySQL database server mysqld                                                                                                                                     [ OK ] invoke-rc.d: could not determine current runlevel
mysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) while connecting to the MySQL server
Upgrade process encountered error and will not continue.
mysql_upgrade failed with exit status 11
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up libhtml-tagset-perl (3.20-2) ...
Setting up liburi-perl (1.71-1) ...
Setting up libhtml-parser-perl (3.72-1) ...
Setting up libcgi-pm-perl (4.26-1) ...
Setting up libfcgi-perl (0.77-1build1) ...
Setting up libcgi-fast-perl (1:2.10-1) ...
Setting up libencode-locale-perl (1.05-1) ...
Setting up libhtml-template-perl (2.95-2) ...
Setting up libtimedate-perl (2.3000-2) ...
Setting up libhttp-date-perl (6.02-1) ...
Setting up libio-html-perl (1.001-1) ...
Setting up liblwp-mediatypes-perl (6.02-1) ...
Setting up libhttp-message-perl (6.11-1) ...
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.23-0ubuntu9) ...
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Processing triggers for systemd (229-4ubuntu19) ...
Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
 mysql-server-5.7
E: Sub-process /usr/bin/dpkg returned an error code (1)

After running sudo apt-get install -f, I get:

Setting up mysql-server-5.7 (5.7.19-0ubuntu0.16.04.1) ...
invoke-rc.d: could not determine current runlevel
 * Stopping MySQL database server mysqld                                                                                                                                     [ OK ] Renaming removed key_buffer and myisam-recover options (if present)
invoke-rc.d: could not determine current runlevel
invoke-rc.d: could not determine current runlevel
 * Stopping MySQL database server mysqld                                                                                                                                     [ OK ] invoke-rc.d: could not determine current runlevel
mysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) while connecting to the MySQL server
Upgrade process encountered error and will not continue.
mysql_upgrade failed with exit status 11
dpkg: error processing package mysql-server-5.7 (--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.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package 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.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

How do I get around these errors and install mysql-server?


0

1

Сначала установил mysql-server и phpmyadmin.

Всё было успешно, но возникли некоторые проблемы с конфигурацией и я решил удалить и то и другое и установить заново.

Удалить получилось но установить снова не получается.

Пытаюсь выполнить sudo apt install mysql-server

Вывод:

dpkg: ошибка при обработке пакета mysql-server-8.0 (--configure):
 installed mysql-server-8.0 package post-installation script subprocess returned error exit status 2
Отчёт apport не записан, так как сообщение об ошибке указывает на повторную ошибку от предыдущего отказа
.
 dpkg: зависимости пакетов не позволяют настроить пакет mysql-server:
 mysql-server зависит от mysql-server-8.0, однако:
  Пакет mysql-server-8.0 пока не настроен.

dpkg: ошибка при обработке пакета mysql-server (--configure):
 проблемы зависимостей — оставляем не настроенным
При обработке следующих пакетов произошли ошибки:
 mysql-server-8.0
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

В общем я не понимаю что происходит так как немного запутался во всех настройках и установках.

Буду благодарен любой помощи.

Понравилась статья? Поделить с друзьями:
  • Ошибка при установке mysql на debian
  • Ошибка при установке mta province
  • Ошибка при установке msvcrt dll
  • Ошибка при установке msi пакетов
  • Ошибка при установке msi windows 10