0

I installed MySQL and MariaDB a few days ago, and was able to produce a table with data in it using MariaDB. I guess I forgot the password, and so I started trying to uninstall MySQL and MariaDB from my machine, and it just was not having it.

I've followed multiple different guides on how to uninstall and then reinstall, but it seems the more I do, the more I mess it up. So, I followed this particular guide here.

I ran through all the steps, and when I get to the install step, I run:

sudo apt-get install mysql-server

Here is the output I get:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libaio1 libevent-core-2.0-5 mysql-client-5.7 mysql-client-core-5.7
  mysql-common mysql-server-5.7 mysql-server-core-5.7
Suggested packages:
  mailx tinyca
The following NEW packages will be installed:
  libaio1 libevent-core-2.0-5 mysql-client-5.7 mysql-client-core-5.7
  mysql-common mysql-server mysql-server-5.7 mysql-server-core-5.7
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/18.7 MB of archives.
After this operation, 161 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 437811 files and directories currently installed.)
Preparing to unpack .../mysql-common_1%3a10.3.18+maria~xenial_all.deb ...
Unpacking mysql-common (1:10.3.18+maria~xenial) ...
Selecting previously unselected package libaio1:amd64.
Preparing to unpack .../libaio1_0.3.110-2_amd64.deb ...
Unpacking libaio1:amd64 (0.3.110-2) ...
Selecting previously unselected package mysql-client-core-5.7.
Preparing to unpack .../mysql-client-core-5.7_5.7.27-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-client-core-5.7 (5.7.27-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-client-5.7.
Preparing to unpack .../mysql-client-5.7_5.7.27-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-client-5.7 (5.7.27-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-server-core-5.7.
Preparing to unpack .../mysql-server-core-5.7_5.7.27-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-server-core-5.7 (5.7.27-0ubuntu0.16.04.1) ...
Selecting previously unselected package libevent-core-2.0-5:amd64.
Preparing to unpack .../libevent-core-2.0-5_2.0.21-stable-2ubuntu0.16.04.1_amd64.deb ...
Unpacking libevent-core-2.0-5:amd64 (2.0.21-stable-2ubuntu0.16.04.1) ...
Processing triggers for libc-bin (2.23-0ubuntu11) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up mysql-common (1:10.3.18+maria~xenial) ...
(Reading database ... 437973 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.27-0ubuntu0.16.04.1_amd64.deb ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
invoke-rc.d returned 5
There is a MySQL server running, but we failed in our attempts to stop it.
Stop it yourself and try again!
dpkg: error processing archive /var/cache/apt/archives/mysql-server-5.7_5.7.27-0ubuntu0.16.04.1_amd64.deb (--unpack):
 subprocess new pre-installation script returned error exit status 1
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.27-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-server (5.7.27-0ubuntu0.16.04.1) ...
Errors were encountered while processing:
 /var/cache/apt/archives/mysql-server-5.7_5.7.27-0ubuntu0.16.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

The parts that keep on bugging me are these:

There is a MySQL server running, but we failed in our attempts to stop it.
Stop it yourself and try again!

and

Errors were encountered while processing:
 /var/cache/apt/archives/mysql-server-5.7_5.7.27-0ubuntu0.16.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I am not Linux expert, so I am extremely confused what any of this could mean. I tried going into my etc/mysql folder and deleting all the contents inside, and still nothing worked.

When running this command: mysqladmin -u root -p status I get this output:

mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!

I also tried: sudo /etc/init.d/mysql stop and got:

[....] Stopping mysql (via systemctl): mysql.serviceFailed to stop mysql.service: Unit mysql.service not loaded.
 failed!

Again, I don't know how to read any of these error commands. I usually just copy and paste them, but some of the guides talk about some stuff I don't know. what is wrong with my MySQL install?

Browse other questions tagged or ask your own question.