Ubuntu – cannot install thesql-server in ubuntu16.0.4

aptdpkgMySQLserver

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

Best Answer

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
```