MySQL "start" fails in ubuntu 20.04 - mysql

I try to run the command:
sudo systemctl start mysql
And receive the following message:
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
Then when i type:
sudo systemctl status mysql.service
I get the following message:
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2021-03-02 11:32:34 IST; 58s ago
Process: 3383 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
Mar 02 11:32:34 avivilloz systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Mar 02 11:32:34 avivilloz systemd[1]: Stopped MySQL Community Server.
Mar 02 11:32:34 avivilloz systemd[1]: mysql.service: Start request repeated too quickly.
Mar 02 11:32:34 avivilloz systemd[1]: mysql.service: Failed with result 'exit-code'.
Mar 02 11:32:34 avivilloz systemd[1]: Failed to start MySQL Community Server.
I searched for hours and couldn't come with a solution... does anyone know what could be the error?
The only thing i did before that was to install mysql-server with the command:
sudo apt-get install mysql-server
I tried installing and reinstalling, updating and upgrading ubuntu, i'm not sure if this would help.
Thanks in advance!
UPDATE:
I just checked, and don't have the /var/lib/mysql directory in my computer. But i failed to get it by reinstalling mysql server/client.

I fixed by "purging" every file related to mysql and reinstalling mysql-server:
sudo apt-get purge mysql-server mysql-client mysql-common
sudo apt-get install mysql-server

In my case the issue is raised b.c the server storage is full.
removing some logs and files solved and then restarting it solved the problem.

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...

Error while starting apache2 server in ubuntu

systemctl start apache2.service
Getting this error:-
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.
Logs of systemctl status apache2.service
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; disabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: failed (Result: exit-code) since Tue 2020-06-02 08:24:55 IST; 49s ago
Process: 9759 ExecStart=/usr/sbin/apachectl start (code=exited, status=127)
Jun 02 08:24:55 GS-4996 systemd[1]: Starting The Apache HTTP Server...
Jun 02 08:24:55 GS-4996 apachectl[9759]: /usr/sbin/apachectl: 174: /usr/sbin/apachectl: /usr/sbin/apache2: not found
Jun 02 08:24:55 GS-4996 apachectl[9759]: Action 'start' failed.
Jun 02 08:24:55 GS-4996 apachectl[9759]: The Apache error log may have more information.
Jun 02 08:24:55 GS-4996 systemd[1]: apache2.service: Control process exited, code=exited status=127
Jun 02 08:24:55 GS-4996 systemd[1]: apache2.service: Failed with result 'exit-code'.
Jun 02 08:24:55 GS-4996 systemd[1]: Failed to start The Apache HTTP Server.
Looks like the apache2 file is not available on server.
/usr/sbin/apache2 is provided by apache2-bin. apache2-bin is a dependency of the apache2 package, so apache2 will not work properly without it. Open the terminal and type:
sudo apt install --reinstall apache2-bin
sudo service apache2 start
Can you please attach error logs or the output of "systemctl status apache2.service"
My Best Solution No Need Restart .. After Long Time of se :)
sudo apt-get --reinstall install apache2-bin
Step 1: Stop nginx & Start apache
That's it.
service nginx stop
systemctl restart postgresql
systemctl restart apache2
systemctl status apache2.service

MYSQL don't start

Previously I performed the migration of my database from one directory to another within the server itself (/var/lib/mysql to /mnt/mysql) for lack of space.
When starting the server again, after having changed the /etc/my.cnf with the correct directory it returns me this error:
$ systemctl start mysqld
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
And when I run the systemctl status command on the mysqld service it returns me:
$ systemctl status mysqld.service
mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Ter 2019-07-16 09:34:44 -03; 44s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 31923 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=1/FAILURE)
Process: 31899 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 31923 (code=exited, status=1/FAILURE)
Status: "SERVER_BOOTING"
Error: 13 (Permission Denied)
Jul 16 09:34:43 srvepl.cettro.local systemd[1]: Starting MySQL Server...
Jul 16 09:34:44 srvepl.cettro.local systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE
Jul 16 09:34:44 srvepl.cettro.local systemd[1]: Failed to start MySQL Server.
Jul 16 09:34:44 srvepl.cettro.local systemd[1]: Unit mysqld.service entered failed state.
Jul 16 09:34:44 srvepl.cettro.local systemd[1]: mysqld.service failed.
If it is permission error, how do I free the server to accept such a directory?
Note: I am using CentOS 7
Thank you!!
If you are using Linux or Unix Server then you should check the permissions of the user to access the service. Here I can see that the user which is logged in can't access the service because of the permission problem.
Try with.
sudo systemctl start mysqld;
Or try sudo su;, enter the creds of the superuser and then try to check the service status.
Or login as superuser and then try to start the service.
Hope this may help you.
After searching i discovered that the error was the 'enforcing' permission of SELINUX.
The answer to fix this problem is:
$ sudo setenforce 0
And the server went up normally.
Are you logged in with root user?
If no, try with sudo.
Otherwise, I think is better to restart your system and try again.
If you aren't expert in linux centos don't manipulate anything.
uninstall mysql and reinstall it.

Can't start mysql server after updating Ubuntu 18.4

first i have tried to uninstall both of them
root#thaali:/etc/mysql# sudo apt-get remove --purge mysql*
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package mysql.cnf
E: Couldn't find any package by glob 'mysql.cnf'
E: Couldn't find any package by regex 'mysql.cnf'
E: Unable to locate package mysql.conf.d
E: Couldn't find any package by glob 'mysql.conf.d'
E: Couldn't find any package by regex 'mysql.conf.d'
Then i have tried to install them
root#thaali:/etc/mysql# sudo apt-get install mysql-server mysql-client
Reading package lists... Done
Building dependency tree... 50%
Building dependency tree
Reading state information... Done
mysql-client is already the newest version (5.7.26-0ubuntu0.19.04.1).
mysql-server is already the newest version (5.7.26-0ubuntu0.19.04.1).
0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.
This is what happen when i tried to restart
root#thaali:/etc/mysql# sudo service mysql start
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
This is what happened when i try to systemctl
root#thaali:/etc/mysql# systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2019-05-29 22:07:43 +0530; 6min ago
Process: 21283 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
මැයි 29 22:07:43 thaali systemd[1]: mysql.service: Control process exited, code=exited, status=1/FAILURE
මැයි 29 22:07:43 thaali systemd[1]: mysql.service: Failed with result 'exit-code'.
මැයි 29 22:07:43 thaali systemd[1]: Failed to start MySQL Community Server.
මැයි 29 22:07:43 thaali systemd[1]: mysql.service: Service RestartSec=100ms expired, scheduling restart.
මැයි 29 22:07:43 thaali systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
මැයි 29 22:07:43 thaali systemd[1]: Stopped MySQL Community Server.
මැයි 29 22:07:43 thaali systemd[1]: mysql.service: Start request repeated too quickly.
මැයි 29 22:07:43 thaali systemd[1]: mysql.service: Failed with result 'exit-code'.
මැයි 29 22:07:43 thaali systemd[1]: Failed to start MySQL Community Server.
This is the error that's throw me when i tried to connect
root#thaali:/etc/mysql# mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Can any one please help me to solve this and i have seen in some places i have edit etc/my.cnf to fix this in my case i don't have such a file
This one is really weird for I was not dist upgrading. One day it just didn't work.
When I tried journalctl -xe I got this
...
Oct 05 08:51:26 <servername> mysql-systemd-start[10914]: ERROR: Unable to start MySQL server:
Oct 05 08:51:26 <servername> mysql-systemd-start[10914]: mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
...
I fixed it by doing this:
sudo mkdir /var/lib/mysql-files
sudo chown -R mysql:mysql /var/lib/mysql-files/
sudo chmod 700 /var/lib/mysql-files/
sudo service mysql restart
Restarting the service didn't actually fix all problems I was having so I ended with rebooting the machine.