11

sudo apt-get install mysql-server fail it blocks at this point

var/lib/dpkg/info/mysql-server-5.7.postinst: line 143: /usr/share/mysql-common/configure-symlinks: No such file or directory

which I found the solution to this bug is comment the line 143 in the /var/lib/dpkg/info/mysql-server-5.7.postinst file.

but my problem is I cannot find the /var/lib/dpkg/info/mysql-server-5.7.postinst file .. not to say comment one line in it .

so how to do to get rid of stuck situation


ps: I have installed mariadb and uninstall it by the steps I googled


update:

I have followed the steps given by the first answer, and it still prompted that error before

surprisingly, this time I can sudo vim /var/lib/dpkg/info/mysql-server-5.7.postinst file and I comment the line 143 , however.. it report another error

ERROR: Unable to start MySQL server:
2017-11-26T08:51:57.033255Z 0 [Note] mysqld (mysqld 5.7.20-0ubuntu0.16.04.1-log) starting as process 22612 ...
2017-11-26T08:51:57.034651Z 0 [ERROR] You have enabled the binary log, but you haven't provided the mandatory server-id. Please refer to the proper server start-up parameters documentation
2017-11-26T08:51:57.035603Z 0 [ERROR] Aborting

6 Answers 6

14

I solved this problem by removing mariadb's deb sources and purging mysql-common and then reinstalling it.

do: sudo apt edit-sources and look for anything containing mariadb like: deb [arch=amd64,arm64,ppc64el] http://ftp.nluug.nl/db/mariadb/repo/10.3/ubuntu bionic main

comment it out by putting a # in front of it. then run

sudo apt update
sudo apt purge mysql-common
sudo apt install mysql-common

after that you can install mysql-server properly via sudo apt install mysql-server

if it ever dissapears from the repo the script was:

#!/bin/sh
set -e

case "$1" in
  install)
    variant="$2"
    my_cnf_path="$3"
    update-alternatives --install /etc/mysql/my.cnf my.cnf "$my_cnf_path" 200
  ;;
  remove)
    variant="$2"
    my_cnf_path="$3"
    update-alternatives --remove my.cnf "$my_cnf_path"
  ;;
esac
```
5
  • 1
    OMFG... Finally. If you've been dancing with Maria and want to switch back to MySQL & have persistent Package mysql-server-5.* is not configured yet errors or any combination there of make sure to remove her source. Thanks.
    – userabuser
    Commented Jun 5, 2019 at 15:56
  • @bigibas123 thanks for your answer. it really helped. Commented Jul 12, 2019 at 12:13
  • Finally! I've tried several other methods, but this was the first one that did it. Thanks!
    – dgo
    Commented Feb 3, 2020 at 17:37
  • First time knowing edit-sources, seriously helpful +1.
    – Liso
    Commented May 26, 2020 at 4:43
  • Worked even in Ubuntu 20.04 and after trying for an hour all other methods which all failed. Thanks.
    – cosmicraga
    Commented Nov 22, 2020 at 21:41
5

Just purge all mysql packages and reinstall:

sudo apt-get remove --purge *mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get install mysql-server mysql_secure_installation
7
  • if you'll edit your answer and add some information to the set of commands you publish as answer, will improve its quality.
    – Yaron
    Commented Nov 26, 2017 at 8:28
  • 1
    @e200 no ..it doesn't work. it still prompt this error /var/lib/dpkg/info/mysql-server-5.7.postinst: line 143: /usr/share/mysql-common/configure-symlinks: No such file or directory Commented Nov 26, 2017 at 8:50
  • @e200: I had a different failure installing mysql-server. And your advice fixed it. The error was, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'". Commented Nov 27, 2017 at 16:32
  • 1
    @AndrewBainbridge Sometimes this happens when you clean up your logs. Commented Nov 28, 2017 at 17:19
  • If my answer helps you, you can upvote it. ;) Commented Nov 28, 2017 at 17:20
3

I fixed the problem by adding a blank file that the install script was looking for and then giving rwx permissions for everyone. Probably not the best way but it worked for me.

    sudo touch /usr/share/mysql-common/configure-symlinks
    sudo chmod 777 /usr/share/mysql-common/configure-symlinks
    sudo apt-get update
    sudo apt-get upgrade
1

Happened to got this when trying to install MariaDB while still having the MySQL 8. You can put the script back and try again with the apt install or remove command.

mysql version: 8.0.25-0ubuntu0.20.04.1

/usr/share/mysql-common/configure-symlinks

#!/bin/sh
set -e

case "$1" in
  install)
    variant="$2"
    my_cnf_path="$3"
    update-alternatives --install /etc/mysql/my.cnf my.cnf "$my_cnf_path" 200
  ;;
  remove)
    variant="$2"
    my_cnf_path="$3"
    update-alternatives --remove my.cnf "$my_cnf_path"
  ;;
esac
0

I had mysql5.7 already running on 16.04.7, but apt was still trying to configure it and erroring out. I tried creating the artificial symlink to get past the line 143 error in the postinstall script without any luck - it would stop and not properly start mysqld...

My solution was to put "exit 0" at the top of the postinstall script and run "apt upgrade" and then remove "exit 0" and save it. Now mysqld is not shut down whenever apt upgrade is run.

0

I was getting below error while installing mysql server on ubuntu and I previously I had installed mariadb.

Error :

I solved this problem, Simple Steps mentioned below.

  1. Edit APT source list file

sudo vim /etc/apt/sources.list

  1. Comment All mariadb URL lines

  2. Save the file

  3. sudo apt update

  4. sudo apt purge mysql-*

  5. sudo rm -rf /etc/mysql /var/lib/mysql

  6. sudo apt install mysql-server

  7. sudo service mysql status

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .