# mySQL server refused to be installed on Ubuntu 18.04

**URL:** <https://forum.freecodecamp.org/t/mysql-server-refused-to-be-installed-on-ubuntu-18-04/351969>\
**Category:** General\
**Created:** [February 20, 2020, 7:25pm UTC](https://forum.freecodecamp.org/t/mysql-server-refused-to-be-installed-on-ubuntu-18-04/351969 "2020-02-20T19:25:44Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhouxiang19910319](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/zhouxiang19910319/32/98849_2.png) [@zhouxiang19910319](https://forum.freecodecamp.org/u/zhouxiang19910319)\
**Post date:** [February 20, 2020, 7:25pm UTC](https://forum.freecodecamp.org/t/mysql-server-refused-to-be-installed-on-ubuntu-18-04/351969/1 "2020-02-20T19:25:44Z")

</div>

_Guys sorry for the harsh tone I am just simply want to solve this issue asap._

steps I took:

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

```

errors I got :

```auto
Setting up mysql-server-5.7 (5.7.29-0ubuntu0.18.04.1) ...
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)
dpkg: error processing package mysql-server-5.7 (--configure):
 installed mysql-server-5.7 package post-installation script subprocess returned error exit status 1
No apport report written because the error message indicates its a followup error from a previous failure.
                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.27-3ubuntu1) ...
Processing triggers for systemd (237-3ubuntu10.39) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for ureadahead (0.100.0-21) ...
Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

```

I did a simple google search about the main error :

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

> web site I went to : [[Solved] “sub process usr bin dpkg returned an error code 1″](https://itsfoss.com/dpkg-returned-an-error-code-1/)

it tells me there are a few ways to do a work around :

I tried them all but they all did not work.

On stackoverflow I saw this so I gave it a try: [mysql-server-5.7 is not configured yet - Stack Overflow](https://stackoverflow.com/questions/58961079/mysql-server-5-7-is-not-configured-yet)

```auto
sudo apt purge mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7 mysql-server-core-5.7 mysql-server

sudo apt update && sudo apt dist-upgrade && sudo apt autoremove && sudo apt -f install

sudo apt install mysql-server

```

Still gives me the same error.

What steps should I take now.

is it because I installed XAMPP before SQL server???

---

<div class="post-metadata">

**Author:** ![zhouxiang19910319](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/zhouxiang19910319/32/98849_2.png) [@zhouxiang19910319](https://forum.freecodecamp.org/u/zhouxiang19910319)\
**Post date:** [February 20, 2020, 7:30pm UTC](https://forum.freecodecamp.org/t/mysql-server-refused-to-be-installed-on-ubuntu-18-04/351969/2 "2020-02-20T19:30:36Z")

</div>

**also another thing is I am doing all these because I got this error when trying to setup OctoberCMS:**

 ![screencapture-localhost-buddhistblog-install-php-2020-02-21-03_26_59](https://global.discourse-cdn.com/freecodecamp/original/3X/4/d/4d4ac1d7156fedd969365578c5093c07fe904dcb.png)

---

<div class="post-metadata">

**Author:** ![zhouxiang19910319](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/zhouxiang19910319/32/98849_2.png) [@zhouxiang19910319](https://forum.freecodecamp.org/u/zhouxiang19910319)\
**Post date:** [February 20, 2020, 7:34pm UTC](https://forum.freecodecamp.org/t/mysql-server-refused-to-be-installed-on-ubuntu-18-04/351969/4 "2020-02-20T19:34:46Z")

</div>

yes it does… but it keeps giving me the error above…  
so I thought it was bceasue I did not install mySQL server + mySQL client on my machine…

---

<div class="post-metadata">

**Author:** ![KittyKora](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kittykora/32/124629_2.png) [@KittyKora](https://forum.freecodecamp.org/u/KittyKora)\
**Post date:** [February 20, 2020, 8:48pm UTC](https://forum.freecodecamp.org/t/mysql-server-refused-to-be-installed-on-ubuntu-18-04/351969/5 "2020-02-20T20:48:32Z")

</div>

Welcome to the world of Linux lol. Best thing to do if it doesn’t work try finding an alternative :3

---

<div class="post-metadata">

**Author:** ![zhouxiang19910319](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/zhouxiang19910319/32/98849_2.png) [@zhouxiang19910319](https://forum.freecodecamp.org/u/zhouxiang19910319)\
**Post date:** [February 20, 2020, 9:57pm UTC](https://forum.freecodecamp.org/t/mysql-server-refused-to-be-installed-on-ubuntu-18-04/351969/6 "2020-02-20T21:57:01Z")

</div>

Gavin Belson: “Fuck!”

 ![fuck](https://global.discourse-cdn.com/freecodecamp/original/3X/7/6/76556bfdb1dee1d25074e73ed6b1ec8ea9ea18d7.jpeg)

---

<div class="post-metadata">

**Author:** ![charmming](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/charmming/32/134210_2.png) [@charmming](https://forum.freecodecamp.org/u/charmming)\
**Post date:** [February 21, 2020, 2:58pm UTC](https://forum.freecodecamp.org/t/mysql-server-refused-to-be-installed-on-ubuntu-18-04/351969/7 "2020-02-21T14:58:32Z")

</div>

I did came across this problem too one time like that and the way i solved it is by removing all files and folders related to mysql using this command below which i got from the link below the commands and it did work for me. Try and lets see if it will work for you too…

```auto
sudo apt-get **remove** -- **purge mysql** *
sudo apt-get **purge mysql** *
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get **remove** dbconfig- **mysql** 
sudo apt-get dist-upgrade
sudo apt-get **install mysql** - **server** 

```

this is the link that helped me out…

> **[Uninstall or Completely remove mysql from ubuntu 16-04](https://linuxscriptshub.com/uninstall-completely-remove-mysql-ubuntu-16-04/)**
>
> While upgrading from ubuntu 16.04.1 to ubuntu 16.04.03, we had face once issue that we unexpected. This incident are cause by mysql server update, while setting up the mysql by apt, its hang on the server and will not work for leaving it around one...

---

<div class="post-metadata">

**Author:** ![chuckadams](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/chuckadams/32/109651_2.png) [@chuckadams](https://forum.freecodecamp.org/u/chuckadams)\
**Post date:** [February 21, 2020, 3:06pm UTC](https://forum.freecodecamp.org/t/mysql-server-refused-to-be-installed-on-ubuntu-18-04/351969/8 "2020-02-21T15:06:47Z")

</div>

This is why you shouldn’t install stuff like XAMPP or any of those other prepackaged stacks on Linux – they’re usually packaged poorly and confuse the package manager at best and screw up your entire system at worst. Just install and configure them separately, which is something you’ll have to do in real world situations anyway.

---

<div class="post-metadata">

**Author:** ![zhouxiang19910319](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/zhouxiang19910319/32/98849_2.png) [@zhouxiang19910319](https://forum.freecodecamp.org/u/zhouxiang19910319)\
**Post date:** [February 22, 2020, 2:02am UTC](https://forum.freecodecamp.org/t/mysql-server-refused-to-be-installed-on-ubuntu-18-04/351969/9 "2020-02-22T02:02:26Z")

</div>

hmmm lesson learnt… =.=

---

<div class="post-metadata">

**Author:** ![zhouxiang19910319](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/zhouxiang19910319/32/98849_2.png) [@zhouxiang19910319](https://forum.freecodecamp.org/u/zhouxiang19910319)\
**Post date:** [February 22, 2020, 2:12am UTC](https://forum.freecodecamp.org/t/mysql-server-refused-to-be-installed-on-ubuntu-18-04/351969/10 "2020-02-22T02:12:21Z")

</div>

@chuckadams @charmming

I will set up a VM and try install in it see how it goes.

---

<div class="post-metadata">

**Author:** ![tuo](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/tuo/32/134330_2.png) [@tuo](https://forum.freecodecamp.org/u/tuo)\
**Post date:** [February 22, 2020, 7:17am UTC](https://forum.freecodecamp.org/t/mysql-server-refused-to-be-installed-on-ubuntu-18-04/351969/11 "2020-02-22T07:17:09Z")

</div>

Have you resolve this problem? What is your operating system? I installed XAMP linux on my linux mint machine and it works with no problem.

---

<div class="post-metadata">

**Author:** ![zhouxiang19910319](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/zhouxiang19910319/32/98849_2.png) [@zhouxiang19910319](https://forum.freecodecamp.org/u/zhouxiang19910319)\
**Post date:** [February 23, 2020, 11:32pm UTC](https://forum.freecodecamp.org/t/mysql-server-refused-to-be-installed-on-ubuntu-18-04/351969/12 "2020-02-23T23:32:16Z")

</div>

Hey, thanks for the reply. And I haven’t been able to solve this issue unfortunately.  
I fired up a VM (same OS, ubuntu 18.04) and tried some steps to install it right there, same error.

---

<div class="post-metadata">

**Author:** ![zhouxiang19910319](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/zhouxiang19910319/32/98849_2.png) [@zhouxiang19910319](https://forum.freecodecamp.org/u/zhouxiang19910319)\
**Post date:** [February 26, 2020, 12:33am UTC](https://forum.freecodecamp.org/t/mysql-server-refused-to-be-installed-on-ubuntu-18-04/351969/13 "2020-02-26T00:33:11Z")

</div>

may I know that what is the version of your linux machine?

---

<div class="post-metadata">

**Author:** ![kerafyrm](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@kerafyrm](https://forum.freecodecamp.org/u/kerafyrm)\
**Post date:** [May 19, 2020, 7:49am UTC](https://forum.freecodecamp.org/t/mysql-server-refused-to-be-installed-on-ubuntu-18-04/351969/14 "2020-05-19T07:49:03Z")

</div>

I use Centos7.

It’s very easy to install.

[https://www.tecmint.com/install-latest-mysql-on-rhel-centos-and-fedora/](https://www.tecmint.com/install-latest-mysql-on-rhel-centos-and-fedora/)

Keep in mind this installs MySQL 8.

Also if you decide to go with fedora, dnf install @mysql works too.

---

<div class="post-metadata">

**Author:** ![mindmaster](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/mindmaster/32/149539_2.png) [@mindmaster](https://forum.freecodecamp.org/u/mindmaster)\
**Post date:** [May 20, 2020, 12:50pm UTC](https://forum.freecodecamp.org/t/mysql-server-refused-to-be-installed-on-ubuntu-18-04/351969/15 "2020-05-20T12:50:05Z")

</div>

XAMPP will conflict easy enough to answer on that. It installs MariaDB which is a fork of MySQL and it grabs the ports. The MySQL install in Ubuntu starts the server to run the configuration process and will never complete if it doesn’t run. It will not run if any other MariaDB/MySQL exists. So, short of the options are:

1. If you’re uncertain of which packages you have laying around back your data, wipe, and reload. Often this is the easiest thing to do with an Ubuntu machine and isn’t as laborious of a process as it would be in Windows or something else. YMMV with this, but at least you are sure then there are no dependency conflicts and you could spend a lot of time fixing that.

2. Manually uninstall the XAMPP package by running its uninstaller in the /opt folder. Make sure you uninstall mysql well, then have another go… You cannot have MariaDB and MySQL on the same computer (they’re the same program, using the same ports, and locking the same resources). Even though this package predominately resides in opt it places scripts and config all over the place. Clean up any of the mysql packages you tried to install, and then attempt to redo it. If this doesn’t work do #1 and stop wasting time. You could spend more time trying to figure it out, but it wouldn’t be worth it. XAMPP doesn’t install things the way that is standard to Ubuntu and this is what causes most of the problems – you essentially are troubleshooting the weirdness this package injects into your system.

You should normally install “LAMP” in ubuntu with, not using XAMPP:

> sudo apt-get install tasksel  
> sudo tasksel install lamp-server

That will install apache2, mysql, php, and all dependencies and configure them to be ready to use in the way that is standard to Ubuntu.

---

<div class="post-metadata">

**Author:** ![Sushil1](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@Sushil1](https://forum.freecodecamp.org/u/Sushil1)\
**Post date:** [June 4, 2020, 7:49pm UTC](https://forum.freecodecamp.org/t/mysql-server-refused-to-be-installed-on-ubuntu-18-04/351969/16 "2020-06-04T19:49:51Z")

</div>

Hi @zhouxiang19910319

try this may be it will help for ubantu 18.04

1

I had the same problem.

I solved it by purging the configuration.

1. Create a backup of all your data: `mysqldump -u root -p --all-databases > ~/alldb.sql`
2. Remove packages and purge configuration¹ `sudo apt purge "mysql-server-*"`
3. Reinstall the MySQL server: `sudo apt install mysql-server` , you should see `Running queries to upgrade MySQL server.` and it will show every table in your database

---

<div class="post-metadata">

**Author:** ![zhouxiang19910319](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/zhouxiang19910319/32/98849_2.png) [@zhouxiang19910319](https://forum.freecodecamp.org/u/zhouxiang19910319)\
**Post date:** [June 7, 2020, 9:33am UTC](https://forum.freecodecamp.org/t/mysql-server-refused-to-be-installed-on-ubuntu-18-04/351969/17 "2020-06-07T09:33:25Z")

</div>

Thank you for the in depth explanation. However right now I have to pause all coding activities. And if I try out your solution later I will post my result/outcome here. Thanks.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [June 1, 2021, 6:51pm UTC](https://forum.freecodecamp.org/t/mysql-server-refused-to-be-installed-on-ubuntu-18-04/351969/18 "2021-06-01T18:51:12Z")

</div>

Closed on June 1, 2021, 6:51pm UTC


