0

I'm using Google cloud and I have a vm (Ubuntu 18.04) that is working fine. The apt-get command works totally fine and mysql service is running well. Let's call it vm-1

I needed to create another a duplicate vm, so I first made a snapshot of vm-1, and used this snapshot to created a new vm, called vm-2.

As I work on vm-2, I found that the simply command of sudo apt-get install *** would fail and get stuck at a step related to mysql-server. Below is an example:

John@vm-2:~$ sudo apt-get install tree
Reading package lists... Done
Building dependency tree
Reading state information... Done
tree is already the newest version (1.7.0-5).
The following packages were automatically installed and are no longer required:
  libnvidia-common-390 linux-gcp-headers-5.0.0-1033
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 170 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up mysql-server-5.7 (5.7.30-0ubuntu0.18.04.1) ...
/var/lib/mysql/ibdata1: 14143
ERROR: Database files are locked. Daemon already running?
Warning: Unable to start the server. Please restart MySQL and run mysql_upgrade to ensure the database is ready for use.
/var/lib/mysql/ibdata1: 14143
ERROR: Database files are locked. Daemon already running?
Warning: Unable to start the server.
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Wed 2020-08-12 18:11:39 JST; 7ms ago
  Process: 24068 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
  Process: 24046 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 1711 (code=exited, status=0/SUCCESS)
dpkg: error processing package mysql-server-5.7 (--configure):
 installed mysql-server-5.7 package post-installation script subprocess returned error exit status 1
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
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
John@vm-2:~$

It keeps saying that

ERROR: Database files are locked. Daemon already running?
Warning: Unable to start the server. Please restart MySQL and run mysql_upgrade to ensure the database is ready for use.
/var/lib/mysql/ibdata1: 14143
ERROR: Database files are locked. Daemon already running?
Warning: Unable to start the server.

How is apt-get related to mysql-server in the first place?? I have always thought that they are 2 independent softwares.

How can I fix this issue? I have done nothing but restoring a snapshot that works totally fine in the original vm. With everything being the same, how come apt-get would fail?

1 Answers1

1

The following log line : 2 not fully installed or removed. suggests that apt-get is trying to complete an earlier failed package installation (mysql-server-5.7) before proceeding with the new installation request (tree), which is why you see mysql-server mentioned in that output.

I would suggest identifying if mysql server is already running via ps -ef | grep -i mysql or netstat -lntp | grep 3306 and resolving the issue causing ERROR: Database files are locked. Daemon already running?

one this is resolved, it will allow the previous package installation to complete successfully

  1. If you started mysql yourself manually, then I would suggest stopping that process, and running the original command again.

  2. If it's possible that if you started mysql at some point previously as root, you might want to check the permissions on the files in the /var/lib/mysql/ibdata1 folder

Tom
  • 11,176
  • 5
  • 41
  • 63
  • awesome! I did `sudo kill` on whatever processes that showed up on `ps -ef | grep -i mysql` and then purged and reinstalled mysql. – Kid_Learning_C Aug 16 '20 at 14:15