1

How can I get Mariadb running again? My WordPress site is returning:

Error establishing a database connection

It seems that my database is down. (I updated Ubuntu 19.04 to 19.10 and have had multiple problems.)

I went ahead and checked for MySQL installed packages, forgetting that I was actually using Mariadb.

So I installed MySQL; discovered I should not have done that; removed MySQL; and followed these instructions to install Mariadb 10.4.

sudo apt install mariadb-server is returning:

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:

mariadb-server : Depends: mariadb-server-10.4 (>= 1:10.4.8+maria~disco) but it is not going to be installed


So I removed Mariadb by doing (source)

apt-get remove --purge mysql*
apt-get remove --purge mysql
apt-get remove --purge mariadb
apt-get remove --purge mariadb*
apt-get --purge remove mariadb-server
apt-get --purge remove python-software-properties

And tried to reinstalling it, again, using the same guide mentioned above:

sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8

this last command apt-key ... returns

Executing: /tmp/apt-key-gpghome.XsKKHEPfCn/gpg.1.sh --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8

gpg: key F1656F24C74CD1D8: 6 signatures not checked due to missing keys

gpg: key F1656F24C74CD1D8: "MariaDB Signing Key " not changed

gpg: Total number processed: 1

gpg: unchanged: 1

sudo apt update
sudo apt install mariadb-server
# MariaDB 10.4 repository list - created 2019-11-03 16:26 UTC
# http://downloads.mariadb.org/mariadb/repositories/
deb [arch=amd64] http://mariadb.mirror.pcextreme.nl/repo/10.4/ubuntu disco main
deb-src http://mariadb.mirror.pcextreme.nl/repo/10.4/ubuntu disco main

sudo systemctl start mariadb returns

Failed to start mariadb.service: Unit mariadb.service not found.


dpkg -l | grep -e mysql -e mariadb returns

rc  automysqlbackup                                       2.6+debian.4-1                                        all          daily, weekly and monthly backup for your MySQL database
ii  dbconfig-mysql                                        2.0.11ubuntu2                                         all          dbconfig-common MySQL/MariaDB support
ii  default-mysql-client                                  1.0.5ubuntu2                                          all          MySQL database client binaries (metapackage)
ii  libdbd-mysql-perl:amd64                               4.050-2build1                                         amd64        Perl5 database interface to the MariaDB/MySQL database
rc  libmysqlclient18:amd64                                5.6.30-0ubuntu0.15.10.1                               amd64        MySQL database client library
ii  libmysqlclient21:amd64                                8.0.17-0ubuntu2                                       amd64        MySQL database client library
ii  mysql-client                                          8.0.17-0ubuntu2                                       all          MySQL database client (metapackage depending on the latest version)
ii  mysql-client-8.0                                      8.0.17-0ubuntu2                                       amd64        MySQL database client binaries
ii  mysql-client-core-8.0                                 8.0.17-0ubuntu2                                       amd64        MySQL database core client binaries
ii  mysql-common                                          1:10.4.8+maria~disco                                  all          MariaDB database common files (e.g. /etc/mysql/my.cnf)
ii  mysql-server-8.0                                      8.0.17-0ubuntu2                                       amd64        MySQL database server binaries and system database setup
ii  mysql-server-core-8.0                                 8.0.17-0ubuntu2                                       amd64        MySQL database server binaries
rc  mysql-utilities                                       1.6.4-1                                               all          collection of scripts for managing MySQL servers
rc  php7.0-mysql                                          7.0.24-1+ubuntu17.04.1+deb.sury.org+1                 amd64        MySQL module for PHP
ii  php7.1-mysql                                          7.1.16-1+ubuntu17.10.1+deb.sury.org+1                 amd64        MySQL module for PHP
ii  postfix-mysql                                         3.4.5-1ubuntu1                                        amd64        MySQL map support for Postfix
ii  roundcube-mysql                                       1.3.8+dfsg.1-2                                        all          metapackage providing MySQL dependencies for RoundCube

Update 1

It looks like I have two sets of databases. I found one in /var/lib/mysql-10.2 and another in /var/lib/mysql. /var/lib/mysql-upgrade is empty.

Update 2

I followed these steps and stopped where it states

But it may not help, as your system is seriously broken, ...

here are some outputs:

sudo apt-get update:

Hit:1 http://archive.canonical.com/ubuntu eoan InRelease
Get:2 http://security.ubuntu.com/ubuntu eoan-security InRelease [92.9 kB]
Hit:3 http://ppa.launchpad.net/webupd8team/y-ppa-manager/ubuntu eoan InRelease 
Hit:4 http://archive.ubuntu.com/ubuntu eoan InRelease                          
Get:5 http://archive.ubuntu.com/ubuntu eoan-updates InRelease [88.4 kB]                         
Fetched 181 kB in 1s (135 kB/s)     
Reading package lists... Done

sudo apt-get install -f:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

sudo apt-get dist-upgrade:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

apt-cache policy python3:

python3:
  Installed: 3.7.5-1
  Candidate: 3.7.5-1
  Version table:
 *** 3.7.5-1 500
        500 http://archive.ubuntu.com/ubuntu eoan/main amd64 Packages
        100 /var/lib/dpkg/status

sudo apt install mariadb-server:

Reading package lists... Done
Building dependency tree       
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:
 mariadb-server : Depends: mariadb-server-10.3 (>= 1:10.3.17-1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Update 3

I noticed /var/run has no mysql folder ... I am assuming mysqldb is not running. So I tried this:

sudo /etc/init.d/mysql start

[....] Starting mysql (via systemctl): mysql.serviceJob for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
 failed!

sudo systemctl status mysql.service

 mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2019-11-03 18:07:45 PST; 44s ago
  Process: 6033 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)

Nov 03 18:07:45 courtens.org systemd[1]: mysql.service: Service RestartSec=100ms expired, scheduling restart.
Nov 03 18:07:45 courtens.org systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Nov 03 18:07:45 courtens.org systemd[1]: Stopped MySQL Community Server.
Nov 03 18:07:45 courtens.org systemd[1]: mysql.service: Start request repeated too quickly.
Nov 03 18:07:45 courtens.org systemd[1]: mysql.service: Failed with result 'exit-code'.
Nov 03 18:07:45 courtens.org systemd[1]: Failed to start MySQL Community Server.

Update 4

I found this and followed the steps, and it finally worked. Or it looked like it would, but I never got the server back.

From the page:

Building MariaDB on Ubuntu

$ sudo apt-get install software-properties-common \
     devscripts \
     equivs

Installing Build Dependencies

$ sudo apt-key adv --recv-keys \
     --keyserver hkp://keyserver.ubuntu.com:80 \
     0xF1656F24C74CD1D8

$ sudo add-apt-repository --update --yes --enable-source \
     'deb [arch=amd64] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.3/ubuntu '$(lsb_release -sc)' main'

$ sudo apt-get build-dep mariadb-10.3

Building MariaDB

...

| improve this question | | | | |
  • Before you do anything more, check you still have your database somewhere in /var/lib; IIRC some versions of the MySQL-related packages deleted the database when they were purged. – Stephen Kitt Nov 3 '19 at 16:52
  • it looks like the db is still there, under /var/lib/mysql/. I also have a dismounted LVM mirror backup to fall back on. – MeSo2 Nov 3 '19 at 18:58
  • All my problem was the wrong repo, I was trying to add eoan, but the server system was bionic. – insign Mar 19 at 4:52
0

I found this post and used aptitude in place of apt-get or apt, and it finally looks like there is some hope...

Instead of using

sudo apt install mariadb-server

I used

sudo aptitude install mariadb-server

and now it started to fix itself

The following NEW packages will be installed:
  galera-3{a} libconfig-inifiles-perl{a} mariadb-client-10.3{ab} mariadb-client-core-10.3{ab} 
  mariadb-common{a} mariadb-server mariadb-server-10.3{ab} mariadb-server-core-10.3{ab} socat{a} 
0 packages upgraded, 9 newly installed, 0 to remove and 0 not upgraded.
Need to get 18.5 MB of archives. After unpacking 161 MB will be used.
The following packages have unmet dependencies:
 mysql-client-8.0 : Conflicts: mariadb-client-10.3 but 1:10.3.17-1 is to be installed
                    Conflicts: virtual-mysql-client which is a virtual package, provided by:
                               - mariadb-client-10.3 (1:10.3.17-1), but 1:10.3.17-1 is to be installed
                               - mysql-client-8.0 (8.0.17-0ubuntu2), but 8.0.17-0ubuntu2 is installed

 mysql-server-8.0 : Conflicts: mariadb-server-10.3 but 1:10.3.17-1 is to be installed
                    Conflicts: virtual-mysql-server which is a virtual package, provided by:
                               - percona-xtradb-cluster-server-5.7 (5.7.20-29.24-0ubuntu3), but it is not going to be installed
                               - mariadb-server-10.3 (1:10.3.17-1), but 1:10.3.17-1 is to be installed
                               - mysql-server-8.0 (8.0.17-0ubuntu2), but 8.0.17-0ubuntu2 is installed

 mariadb-server-core-10.3 : Conflicts: virtual-mysql-server-core which is a virtual package, provided by:
                                       - percona-xtradb-cluster-server-5.7 (5.7.20-29.24-0ubuntu3), but it is not going to be installed
                                       - mariadb-server-core-10.3 (1:10.3.17-1), but 1:10.3.17-1 is to be installed
                                       - mysql-server-core-8.0 (8.0.17-0ubuntu2), but 8.0.17-0ubuntu2 is installed

 mariadb-server-10.3 : Conflicts: virtual-mysql-server which is a virtual package, provided by:
                                  - percona-xtradb-cluster-server-5.7 (5.7.20-29.24-0ubuntu3), but it is not going to be installed
                                  - mariadb-server-10.3 (1:10.3.17-1), but 1:10.3.17-1 is to be installed
                                  - mysql-server-8.0 (8.0.17-0ubuntu2), but 8.0.17-0ubuntu2 is installed

 mysql-client-core-8.0 : Conflicts: mariadb-client-10.3 but 1:10.3.17-1 is to be installed
                         Conflicts: mariadb-client-core-10.3 but 1:10.3.17-1 is to be installed
                         Conflicts: virtual-mysql-client-core which is a virtual package, provided by:
                                    - mariadb-client-core-10.3 (1:10.3.17-1), but 1:10.3.17-1 is to be installed
                                    - mysql-client-core-8.0 (8.0.17-0ubuntu2), but 8.0.17-0ubuntu2 is installed

 mariadb-client-10.3 : Conflicts: virtual-mysql-client which is a virtual package, provided by:
                                  - mariadb-client-10.3 (1:10.3.17-1), but 1:10.3.17-1 is to be installed
                                  - mysql-client-8.0 (8.0.17-0ubuntu2), but 8.0.17-0ubuntu2 is installed

 mariadb-client-core-10.3 : Conflicts: virtual-mysql-client-core which is a virtual package, provided by:
                                       - mariadb-client-core-10.3 (1:10.3.17-1), but 1:10.3.17-1 is to be installed
                                       - mysql-client-core-8.0 (8.0.17-0ubuntu2), but 8.0.17-0ubuntu2 is installed

 mysql-server-core-8.0 : Conflicts: mariadb-server-10.3 but 1:10.3.17-1 is to be installed
                         Conflicts: mariadb-server-core-10.3 but 1:10.3.17-1 is to be installed
                         Conflicts: virtual-mysql-server-core which is a virtual package, provided by:
                                    - percona-xtradb-cluster-server-5.7 (5.7.20-29.24-0ubuntu3), but it is not going to be installed
                                    - mariadb-server-core-10.3 (1:10.3.17-1), but 1:10.3.17-1 is to be installed
                                    - mysql-server-core-8.0 (8.0.17-0ubuntu2), but 8.0.17-0ubuntu2 is installed

The following actions will resolve these dependencies:

     Remove the following packages:                       
1)     default-mysql-client [1.0.5ubuntu2 (eoan, now)]    
2)     mysql-client-8.0 [8.0.17-0ubuntu2 (eoan, now)]     
3)     mysql-client-core-8.0 [8.0.17-0ubuntu2 (eoan, now)]
4)     mysql-server-8.0 [8.0.17-0ubuntu2 (eoan, now)]     
5)     mysql-server-core-8.0 [8.0.17-0ubuntu2 (eoan, now)]

     Install the following packages:                      
6)     mariadb-client [1:10.3.17-1 (eoan)]                



Accept this solution? [Y/n/q/?] 
| improve this answer | | | | |
0

It looks like you fixed it, but I'm guessing the original problem was that not all the necessary packages were purged.

apt-get remove --purge mysql*

only removes packages that start with "mysql". Some packages, as were listed later with

dpkg -l | grep mysql 

have "mysql" within the package name. I'm pretty sure running the dpkg list command after the original purge commands would have found some mysql packages still installed. I had a similar problem and it was because of some "libmysql..." packages. The purge commands needed leading wild cards too. (Sorry, I'm used to the apt syntax, but apt-get works too.)

apt purge *mysql*
apt purge *mariadb*
dpkg --list | grep mysql
dpkg --list | grep mariadb

When grep'ing, I would even go down to "sql" and "maria" just to be really sure. I haven't found it to be necessary, but I like to be really, really sure something is gone when purging.

I'm also a little surprised that the later

apt-get update

command didn't list mariadb repositories. I thought only version 10.1 was available from the standard Ubuntu repositories, and 10.4 was only available from the mariadb repositories (as of Feb 2020). I see these mariadb repositories referenced in the install 10.4 link, but I don't see these repositories in the apt-get update command output.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.