[Solved] Any Softwares Install Error in Ubuntu: /usr/bin/dpkg returned an error code

After reinstalling mysql, I get an error when installing any software

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
wget is already the newest version (1.21.2-2ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 43 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-8.0 (8.0.30-0ubuntu0.22.04.1) ...
Renaming removed key_buffer and myisam-recover options (if present)
Specified filename /var/lib/mysql/ibdata1 does not exist.
mysqld will log errors to /var/log/mysql/error.log
2022-09-02T07:28:00.496933Z 0 [ERROR] [MY-010946] [Server] Failed to start mysqld daemon. Check mysqld error log.
Warning: Unable to start the server.
AppArmor parser error for /etc/apparmor.d/usr.sbin.mysqld in profile /etc/apparmor.d/usr.sbin.mysqld at line 9: Could not open 'abstractions/mysql'
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xeu mysql.service" 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 Fri 2022-09-02 15:28:00 CST; 3ms ago
    Process: 15388 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
        CPU: 6ms
dpkg: error processing package mysql-server-8.0 (--configure):
 installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-8.0; however:
  Package mysql-server-8.0 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-8.0
 mysql-server



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

Solution:

ls -l /var/lib/dpkg/info | grep -i  mysql-server
-rw-r--r-- 1 root root     363 Jul 27 00:14 mysql-server-8.0.conffiles
-rwxr-xr-x 1 root root    1504 Jul 27 00:14 mysql-server-8.0.config
-rw-r--r-- 1 root root    1604 Aug 31 19:00 mysql-server-8.0.list
-rw-r--r-- 1 root root    1112 Jul 27 00:14 mysql-server-8.0.md5sums
-rwxr-xr-x 1 root root   17135 Jul 27 00:14 mysql-server-8.0.postinst
-rwxr-xr-x 1 root root    3873 Jul 27 00:14 mysql-server-8.0.postrm
-rwxr-xr-x 1 root root    5631 Jul 27 00:14 mysql-server-8.0.preinst
-rwxr-xr-x 1 root root     403 Jul 27 00:14 mysql-server-8.0.prerm
-rw-r--r-- 1 root root   21907 Jul 27 00:14 mysql-server-8.0.templates
-rw-r--r-- 1 root root    5232 Aug 31 19:00 mysql-server-core-8.0.list
-rw-r--r-- 1 root root    8318 Jul 27 00:14 mysql-server-core-8.0.md5sums
 mv /var/lib/dpkg/info/mysql-* /tmp
apt-get update

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *