-1

I am trying to install mysql server on my Ubuntu 22.04 LTS but couldnt do that it says unmet dependencies and i tried installing the required dependencies but it didnt work.

sudo apt install mysql-server
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 mysql-common : Conflicts: mysql-server-8.0 but 8.0.29-0ubuntu0.22.04.2 is to be installed
 mysql-server-8.0 : Depends: mysql-client-8.0 (>= 8.0.29-0ubuntu0.22.04.2) but it is not installable
                    Depends: mysql-server-core-8.0 (= 8.0.29-0ubuntu0.22.04.2) but it is not installable
E: Unable to correct problems, you have held broken packages.
karel
  • 110,292
  • 102
  • 269
  • 299
  • `you have requested an impossible situation` generally occurs when there is more to the story that you have so far revealed. Often it includes non-Ubuntu or wrong-version sources that are still cluttering your system. Clean up your previous attempts, and then it will install. – user535733 Jun 17 '22 at 04:07
  • Does this answer your question? [Unable to correct problems, you have held broken packages](https://askubuntu.com/questions/223237/unable-to-correct-problems-you-have-held-broken-packages) – karel Jun 17 '22 at 06:24

2 Answers2

0

Use aptitude instead of apt-get:

sudo aptitude install mysql-server

In the prompt, you should not accept the first solution to force reload of dependences.

If you don't have aptitude on your machine yet, get it with

sudo apt-get install aptitude
  • mysql: Can't read dir of '/etc/mysql/mariadb.conf.d/' (OS errno 2 - No such file or directory) mysql: [ERROR] Stopped processing the 'includedir' directive in file /etc/mysql/my.cnf at line 29. mysql: [ERROR] Fatal error in defaults handling. Program aborted! – Ramu Singamsetty Jul 30 '22 at 06:43
  • I tried the same but it shows this – Ramu Singamsetty Jul 30 '22 at 06:43
-1

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.

I was able to resolve this issue on Ubuntu 22.04 as described below, using arief21's solution to a similar problem on 20.04, which itself was copied from here.

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!

aquilla
  • 109
  • 1
  • 5
  • @aquila I followed your steps but still get: The following packages have unmet dependencies: mysql-common : Conflicts: mysql-server-8.0 but 8.0.30-0ubuntu0.22.04.1 is to be installed Conflicts: mysql-server-core-8.0 but 8.0.30-0ubuntu0.22.04.1 is to be installed mysql-server-8.0 : Depends: mysql-client-8.0 (>= 8.0.30-0ubuntu0.22.04.1) but it is not installable E: Unable to correct problems, you have held broken packages. – CodeConnoisseur Sep 03 '22 at 14:15
  • @CodeConnoisseur do you know if you actually have packages held at a specific version? `apt-mark showhold` will list any held packages. – aquilla Sep 12 '22 at 19:51
  • I had to actually purge all of mysql from my ubuntu installation then re-install from scratch. – CodeConnoisseur Sep 12 '22 at 21:08