Broken mysqld package preventing any other installation in ubuntu - mysql

I am having this issue for quite a long period of time, it started when I wanted to change password for mysql which I forgot. I have followed a lot of documents to purge mysql from my system completely so that I can have a new password for a freshly installed mysql. But every time I install it I face the same problem and it asks me the same old password.
Currently I have purged mysql from my system but even though whenever I try to install anything, let's say openssh, I get the below logs after downloading the package.
sudo apt-get install openssh-server
.
.
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.23-0ubuntu0.20.04.1) ...
Renaming removed key_buffer and myisam-recover options (if present)
mysqld will log errors to /var/log/mysql/error.log
mysqld is running as pid 9069
Job for mysql.service failed because a timeout was exceeded.
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)
Drop-In: /etc/systemd/system/mysql.service.d
└─override.conf
Active: activating (auto-restart) (Result: timeout) since Sat 2021-07-03 00:35:37 IST; 5ms ago
Process: 9257 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Process: 9278 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid --skip-grant-tables --skip-networking (code=exited, status=0/SUCCESS)
Main PID: 9278 (code=exited, status=0/SUCCESS)
Status: "Server shutdown complete"
Error: 2 (No such file or directory)
Jul 03 00:35:37 gp-HP-Pavilion-Notebook systemd[1]: mysql.service: Scheduled restart job, restart counter is at 1.
Jul 03 00:35:37 gp-HP-Pavilion-Notebook systemd[1]: Stopped MySQL Community Server.
Jul 03 00:35:37 gp-HP-Pavilion-Notebook systemd[1]: Starting MySQL Community Server...
Jul 03 00:35:41 gp-HP-Pavilion-Notebook systemd[1]: mysql.service: Got notification message from PID 10009, but reception only permitted for main PID 10007
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)
Is there any way to prevent this from happening every time when I install anything ?
It would be great if anyone could help in resolving this issue, because it is also blocking the proper installation of various other package.

The log says: See "systemctl status mysql.service" and "journalctl -xe" for details.
systemctl status mysql.service will show the status of the mysql.service.
systemctl stop mysql.service will stop the mysql.service.
systemctl start mysql.service will start the mysql.service.
systemctl enable mysql.service will start the mysql.service at boot.
systemctl disable mysql.service will stop the starting of the mysql.service at boot. (I think you need this one)
more info: man systemctl, and systemctl --help

Related

Problems installing MySQL on Ubuntu 22.04.1

I am trying to install MySQL in Ubuntu server 22.04.1 whit but I keep geting this error:
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 Wed 2022-08-17 22:11:24 UTC; 9ms ago
Process: 1461 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Process: 1469 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Main PID: 1469 (code=exited, status=1/FAILURE)
Status: "Server shutdown complete"
Error: 22 (Invalid argument)
CPU: 654ms
Aug 17 22:11:24 SQL systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Aug 17 22:11:24 SQL systemd[1]: mysql.service: Failed with result 'exit-code'.
Aug 17 22:11:24 SQL systemd[1]: Failed to start MySQL Community Server.
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
Setting up libcgi-fast-perl (1:2.15-1) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
Errors were encountered while processing:
mysql-server-8.0
mysql-server
After reading this:
Problems installing MySQL on Ubuntu 20.04
dpkg: error processing package mysql-server (dependency problems)?
I've tried this:
sudo systemctl stop mysql
sudo apt clean
sudo apt purge mysql*
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql
sudo apt autoremove
sudo apt autoclean
sudo apt update
sudo apt dist-upgrade
sudo apt install -f
sudo apt install mysql-server
But I'm still getting the same error
Then I read this:
I did not manage to install mysql on Ubuntu completely
So I tried
sudo mysql_secure_installation
but then I got this error:
Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I am running Ubuntu Server 22.04.1 LTS on a LXC with 4GB of RAM and one CPU core
Edit:
sudo journalctl -u mysql.service -n 60 outputs:
Aug 17 22:24:46 SQL systemd[1]: Starting MySQL Community Server...
Aug 17 22:24:47 SQL systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Aug 17 22:24:47 SQL systemd[1]: mysql.service: Failed with result 'exit-code'.
Aug 17 22:24:47 SQL systemd[1]: Failed to start MySQL Community Server.
Aug 17 22:24:48 SQL systemd[1]: mysql.service: Scheduled restart job, restart counter is at 27.

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

Ok so all of a sudden sql is not working properly on my server. When i run sudo service mysql start it says:
Job for mysql.service failed because a fatal signal was delivered to the control process.
See "systemctl status mysql.service" and "journalctl -xe" for details.
When i run systemctl status mysql.service it shows:
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start) since Wed 2021-04-14 03:08:17 UTC; 4s ago
Process: 12884 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 12892 (mysqld)
Status: "Server startup in progress"
Tasks: 2 (limit: 1136)
Memory: 2.7M
CGroup: /system.slice/mysql.service
└─12892 [mysqld]
When i run journalctl -xe is shows:
Apr 14 03:04:43 otzivio-ubuntu-s-1vcpu-1gb-intel-fra1-01 sudo[11492]: pam_unix(sudo:auth):
authentication failure; logname=ashok uid=1000 euid=0 tty=/dev/pts/0 ruser=ashok rhost= user=ashok
Apr 14 03:04:47 otzivio-ubuntu-s-1vcpu-1gb-intel-fra1-01 sudo[11492]: pam_unix(sudo:auth):
conversation failed
Apr 14 03:04:47 otzivio-ubuntu-s-1vcpu-1gb-intel-fra1-01 sudo[11492]: pam_unix(sudo:auth): auth could
not identify password for [ashok]
Apr 14 03:05:20 otzivio-ubuntu-s-1vcpu-1gb-intel-fra1-01 sudo[11748]: pam_unix(sudo:auth):
authentication failure; logname=ashok uid=1000 euid=0 tty=/dev/pts/0 ruser=ashok rhost= user=ashok
Any help is appreciated
First run " sudo apt-get install -f" for resolve dependences, if it doesn't works, review your config files, permission, etc. Try to see if thare is any update that happened.
In the last case, when nothing works. Try to reinstall by "sudo apt-get autoremove mysql-server && apt-get install mysql-server" but make sure you have all backups os config files and sql...
I don't know if it will really help, but in my job we receve some updates in the server from night to the day that pull all down kkk. After some bad experiences i create the backup of the backp of the backup daily...

MySQL Ubuntu 19.10 Installation Error - System Schema directory does not exist

I have attempted to conduct a clean install of MySQL on my ubuntu19.10 install
However during installs I continue to get the following errors while attempting to install MySql on Ubuntu 191.10.
within /var/log/MySql/error.log:
2020-03-31T02:04:00.133031Z 1 [ERROR] [MY-013178] [Server] Execution of server-side SQL statement 'CREATE SCHEMA mysql DEFAULT COLLATE utf8mb4_0900_ai_ci' failed with error code = 1049, error message = 'System schema directory does not exist.'.
2020-03-31T02:04:00.133738Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2020-03-31T02:04:00.134159Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-03-31T02:04:00.662756Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.19-0ubuntu0.19.10.3) (Ubuntu).
Installing gives the following errors:
$ sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
mysql-server is already the newest version (8.0.19-0ubuntu0.19.10.3).
0 upgraded, 0 newly installed, 0 to remove and 0 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.19-0ubuntu0.19.10.3) ...
Renaming removed key_buffer and myisam-recover options (if present)
mysqld will log errors to /var/log/mysql/error.log
2020-03-31T02:04:00.134301Z 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 /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 -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 Mon 2020-03-30 21:04:03 CDT; 9ms ago
Process: 17035 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
Mar 30 21:04:03 ubuntu-vm systemd[1]: mysql.service: Control process exited, code=exited, status=1/FAILURE
Mar 30 21:04:03 ubuntu-vm systemd[1]: mysql.service: Failed with result 'exit-code'.
Mar 30 21:04:03 ubuntu-vm systemd[1]: Failed to start MySQL Community Server.
dpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 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-8.0; however:
Package mysql-server-8.0 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
mysql-server-8.0
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
Try to install mariadb first sudo apt install mariadb-server
After this you can normally use mysql but if you have any error try to reinstall mysql with this command : sudo apt install mysql-server
Mariadb is the same as MySQL it’s just open source project after the buy of MySQL by oracle so an employee have quit MySQL to create a new SGBD with an high compatibility of MySQL.

Unable to install mysql-server on ubuntu 16.04

This is the terminal output coming when i am trying to install the mysql-server using the command -
sudo apt-get install mysql-server
Terminal o/p
Setting up mysql-community-server (5.7.18-1ubuntu16.04) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
AppArmor parser error for /etc/apparmor.d/usr.sbin.mysqld in /etc/apparmor.d/usr.sbin.mysqld at line 7: 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 -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: failed (Result: exit-code) since Mon 2017-06-12 14:23:11 IST; 7ms ago
Process: 26677 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
Process: 26612 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 23756 (code=exited, status=1/FAILURE)
Jun 12 14:23:06 prat14k systemd[1]: Starting MySQL Community Server...
Jun 12 14:23:07 prat14k mysql-systemd-start[26612]: AppArmor parser error for...
Jun 12 14:23:07 prat14k mysqld[26677]: Initialization of mysqld failed: 0
Jun 12 14:23:07 prat14k systemd[1]: mysql.service: Control process exited, ...=1
Jun 12 14:23:11 prat14k systemd[1]: Failed to start MySQL Community Server.
Jun 12 14:23:11 prat14k systemd[1]: mysql.service: Unit entered failed state.
Jun 12 14:23:11 prat14k systemd[1]: mysql.service: Failed with result 'exit...'.
Hint: Some lines were ellipsized, use -l to show in full.
dpkg: error processing package mysql-community-server (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-community-server (= 5.7.18-1ubuntu16.04); however:
Package mysql-community-server is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.23-0ubuntu7) ...
No apport report written because the error message indicates its a followup error from a previous failure.
Processing triggers for systemd (229-4ubuntu17) ...
Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
mysql-community-server
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
i have tried about 5 times just removing,purging and all other commands, but cannot get it done.
also,
systemctl mysql status
is showing
AppArmor parser error for /etc
Please help
Try removing apparmor package:
sudo apt purge apparmor
and then re-attempt the installation with mysql-common package:
sudo apt install mysql-common mysql-server

Error in installing Mysql-server in ubuntu16.04

Here is the error i am getting
Setting up mysql-server-5.7 (5.7.12-0ubuntu1.1) ...
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.
dpkg: error processing package mysql-server-5.7 (--configure):
subprocess installed post-installation script 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
Processing triggers for man-db (2.7.5-1) ...
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)
After following instruction as said in line 2 of above code, i am getting
$ systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en
Active: activating (start-post) (Result: exit-code) since Tue 2016-07-05 18:2
Process: 7822 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 7819 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exit
Main PID: 7822 (code=exited, status=1/FAILURE); : 7823 (mysql-systemd-s
CGroup: /system.slice/mysql.service
└─control
├─7823 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─7874 sleep 1
$ journalctl -xe
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has failed.
--
-- The result is failed.
Jul 05 18:29:59 rahul-HP-2000-Notebook-PC systemd[1]: mysql.service: Unit entere
Jul 05 18:29:59 rahul-HP-2000-Notebook-PC systemd[1]: mysql.service: Failed with
Jul 05 18:29:59 rahul-HP-2000-Notebook-PC systemd[1]: mysql.service: Service hol
Jul 05 18:29:59 rahul-HP-2000-Notebook-PC systemd[1]: Stopped MySQL Community Se
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has finished shutting down.
Jul 05 18:29:59 rahul-HP-2000-Notebook-PC systemd[1]: Starting MySQL Community S
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has begun starting up.
I have tried reinstalling it many times but it always shows the same error. What can be the reason fot this error ?
Remove all mysql packages with purge:
$ sudo apt-get remove --purge mysql*
$ sudo apt-get autoremove --purge
If the directory /etc/mysql still exists, even after executing the commands above, then force its removal:
$ sudo rm -rf /etc/mysql
Now, first of all, install package mysql-client:
$ sudo apt-get install mysql-client
Finally, install package mysql-server after mysql-client has been successfully installed:
$ sudo apt-get install mysql-server
The commands described above were the only way I found to fix the installation error on mysql-server.
I have tried all solutions described in the links below, but none of them works!
https://askubuntu.com/questions/766038/error-installing-mysql-on-ubuntu-16-04
https://askubuntu.com/questions/760724/16-04-upgrade-broke-mysql-server
https://ubuntuforums.org/showthread.php?t=2325143
https://bugs.launchpad.net/ubuntu/+source/mysql-5.7/+bug/1573279
https://askubuntu.com/questions/760724/16-04-upgrade-broke-mysql-server