mysql.service failed because the control process exited with error code - mysql

I've looked at the various solutions from other threads but can't possibly figure this out; and solutions I've found aren't applying here. I'm running Ubuntu 16.04 LTS and spun up a server a few days ago. The server has been running fine until it didn't. After taking 15 miniutes to shutdown, I have now booted and MySQL won't start:
systemctl1 status mysql.service
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) (Result: exit-code) since Wed 2017-03-01 09:04:59 GMT; 18s ago
Process: 6969 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 6967 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 6969 (code=exited, status=1/FAILURE); : 6970 (mysql-systemd-s)
CGroup: /system.slice/mysql.service
└─control
├─6970 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─7080 sleep 1
sudo journalctl -xe
Mar 01 09:08:31 dwight systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
/var/log/mysql/error.log.1 is showing no errors today (the day MySQL crashed) but has been logging up until yesterday. /var/log/mysql/error.log is empty.
Please can anyone advise on how to diagnose?

Try this:
sudo service mysql start

Related

Can't start MySQL without skip-grant-tables: Job for mysql.service failed because the control process exited with error code

When I have
[mysqld]
skip-grant-tables
in /etc/mysql/mysql.conf.d/mysqld.cnf file
service mysql start
works fine.
However when I comment it out:
[mysqld]
#skip-grant-tables
I get a
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
error. Why? How do I fix it?
systemctl status mysql.service
Gives this
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start) since Mon 2022-09-26 12:40:00; 569ms ago
Process: 791228 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 791236 (mysqld)
Status: "Server startup in progress"
Tasks: 21 (limit: 38267)
Memory: 343.6M
CGroup: /system.slice/mysql.service
└─791236 /usr/sbin/mysqld
Sep 26 22:40:00 copper systemd[1]: Starting MySQL Community Server...

MySQL 8 & RHEL 7 - starting services automatically is failing

I'm trying to shutdown and startup a MySQL 8 installation gracefully on reboot.
I've enable the service with systemctl with the following command.
systemctl enable rh-mysql80-mysqld.service
After rebooting I check the status
root#localhost > systemctl status rh-mysql80-mysqld.service
● rh-mysql80-mysqld.service - MySQL 8.0 database server
Loaded: loaded (/usr/lib/systemd/system/rh-mysql80-mysqld.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2022-03-11 12:18:24 PST; 16min ago
Process: 1635 ExecStopPost=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /opt/rh/rh-mysql80/root/usr/libexec/mysql-wait-stop (code=exited, status=0/SUCCESS)
Process: 1242 ExecStart=/opt/rh/rh-mysql80/root/usr/libexec/mysqld-scl-helper enable $RH_MYSQL80_SCLS_ENABLED -- /opt/rh/rh-mysql80/root/usr/libexec/mysqld --basedir=/opt/rh/rh-mysql80/root/usr (code=exited, status=1/FAILURE)
Process: 1165 ExecStartPre=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /opt/rh/rh-mysql80/root/usr/libexec/mysql-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Process: 1098 ExecStartPre=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /opt/rh/rh-mysql80/root/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Process: 1059 ExecStartPre=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /usr/bin/scl_enabled rh-mysql80 (code=exited, status=0/SUCCESS)
Main PID: 1242 (code=exited, status=1/FAILURE)
Status: "Server startup in progress"
I see this in the mysqld.log
/var/log/mysql/mysqld.log
2022-03-11T20:18:24.356194Z 0 [ERROR] [MY-011811] [Server] Can't start server: can't check PID filepath: No such file or directory
After executing the following commands I am able to manually start the service
[root#localhost ~]# sudo mkdir -p /var/run/rh-mysql80-mysqld/
[root#localhost ~]# sudo chown mysql.mysql /var/run/rh-mysql80-mysqld/
[root#localhost ~]# systemctl status rh-mysql80-mysqld.service
● rh-mysql80-mysqld.service - MySQL 8.0 database server
Loaded: loaded (/usr/lib/systemd/system/rh-mysql80-mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2022-03-11 12:58:16 PST; 58s ago
Process: 1635 ExecStopPost=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /opt/rh/rh-mysql80/root/usr/libexec/mysql-wait-stop (code=exited, status=0/SUCCESS)
Process: 14780 ExecStartPost=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /opt/rh/rh-mysql80/root/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
Process: 14678 ExecStartPre=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /opt/rh/rh-mysql80/root/usr/libexec/mysql-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Process: 14647 ExecStartPre=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /opt/rh/rh-mysql80/root/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Process: 14641 ExecStartPre=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /usr/bin/scl_enabled rh-mysql80 (code=exited, status=0/SUCCESS)
Main PID: 14721 (mysqld)
Status: "Server is operational"
CGroup: /system.slice/rh-mysql80-mysqld.service
└─14721 /opt/rh/rh-mysql80/root/usr/libexec/mysqld --basedir=/opt/rh/rh-mysql80/root/usr
Mar 11 12:58:15 localhost systemd[1]: Starting MySQL 8.0 database server...
Mar 11 12:58:15 localhost scl[14647]: Socket file /var/lib/mysql/mysql.sock exists.
Mar 11 12:58:15 localhost scl[14647]: No process is using /var/lib/mysql/mysql.sock, which means it is a garbage, so it will be removed automatically.
Mar 11 12:58:16 localhost systemd[1]: Started MySQL 8.0 database server.
Can anyone tell me what needs to be done so that the service can successfully start on reboot without the manual intervention ?
OS Linux 3.10.0-1160.59.1.el7.x86_64 #1 SMP Wed Feb 16 12:17:35 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
UPDATE:
I think I found my problem.
While visiting google university I found other people had "fixed" the same or similar problem by creating a service to create the missing directory in /var/run. I tried this unsuccessfully for an hour or so.
I then stumbled across a MySQL bug report which sent me on a search to locate this file.
-rw-r--r-- 1 root root 44 Sep 16 05:05 /usr/lib/tmpfiles.d/rh-mysql80-mysqld.conf
The contents of this file
d /run/rh-mysql80-mysqld 0755 mysql mysql -
If this file exists, why is it not working. I took a look in /varlog/messages and found this:
Mar 11 15:43:03 systemd-tmpfiles: [/usr/lib/tmpfiles.d/rh-mysql80-mysqld.conf:1] Unknown group 'mysql'.
Mar 11 15:43:03 systemd: systemd-tmpfiles-setup.service: main process exited, code=exited, status=1/FAILURE
Mar 11 15:43:03 systemd: Unit systemd-tmpfiles-setup.service entered failed state.
Mar 11 15:43:03 systemd: systemd-tmpfiles-setup.service failed.
"mysql" wasnt in the /etc/group file (despite the groupadd command saying that it already existed) so I manually added it.
Made this change, rebooted.... and BOOM!!....Mysql started automatically!

ERROR 2006 (HY000): MySQL server has gone away & conflict with max_allowed_packet

I wanted to import a sql dump
mysql -u username mydb < file.sql
And of course i get the classic ERROR 2006 (HY000) at line 1701: MySQL server has gone away message. No big deal i know that i need to increase the packet size. So i edit the /etc/mysql/mysql.cnf file and add the line max_allowed_packet=64M. But when i try to start the mysql server i get an error.
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2019-01-21 16:27:47 CET; 15s ago
Process: 9151 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
Process: 9112 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 27620 (code=exited, status=0/SUCCESS)
Jan 21 16:27:47 aleksandar-pc systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Jan 21 16:27:47 aleksandar-pc systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Jan 21 16:27:47 aleksandar-pc systemd[1]: Stopped MySQL Community Server.
Jan 21 16:27:47 aleksandar-pc systemd[1]: mysql.service: Start request repeated too quickly.
Jan 21 16:27:47 aleksandar-pc systemd[1]: mysql.service: Failed with result 'exit-code'.
If i remove the code added for packets, the server can be started normally.
Can anyone help me with this, i really need to import this large db and don't know how to fix this mysql error.
Mysql verison: Ver 14.14 Distrib 5.7.25, for Linux (x86_64)
Linux: Ubuntu 18.04 LTS
Ok i forgot this [mysqld] above:
[mysqld]
max_allowed_packet=128M

MySQL 5.7 Upgrade error on Ubuntu 16.04

I was just uninstalling nginx and then in that apt-get remove command, I see that mysql-server is updating. Then the update hung up. I killed the "apt-get" process (followed some answer somewhere). Then things kept on happening and the mysql was completely screwed up. I followed #jargonjunkie 's answer here: https://askubuntu.com/questions/763534/cannot-reinstall-mysql-server-after-its-purge also but to no avail.
(I have even removed /var/lib/mysql and /etc/mysql).
Here's what happens when I try to start mysql:
root#lamp-512mb-nyc1-01:~/etc/mysql# sudo /etc/init.d/mysql start
[....] Starting mysql (via systemctl): mysql.serviceJob for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
failed!
Here's what "systemctl status mysql.service" shows:
root#lamp-512mb-nyc1-01:~/etc/mysql# systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) (Result: exit-code) since Tue 2017-10-24 13:40:38 UTC; 13s ago
Process: 21324 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 21315 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 21324 (code=exited, status=1/FAILURE); : 21325 (mysql-systemd-s)
Tasks: 2
Memory: 18.2M
CPU: 423ms
CGroup: /system.slice/mysql.service
└─control
├─21325 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─21357 sleep 1
Oct 24 13:40:38 lamp-512mb-nyc1-01 systemd[1]: Starting MySQL Community Server...
Oct 24 13:40:38 lamp-512mb-nyc1-01 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
I have seen several questions related to mysql-server 5.7 upgrade on ubuntu, but couldn't find anything that worked.
Please help. Thanks in advance.
Save your data (/var/lib/mysql) and totally remove MySQL:
apt purge mysql* mariadb*
Remove files files from /var/lib/mysql, /etc/mysql, /lib/systemd/system/mysql.service, /usr/share/mysql
Install MySQL again
Check if it starts
Bring data back (if needed)
Check logs journalctl -xe

Webmin MySQL Error on starting

Firstly, I must say that I have not used these tools in the past so linux commands are not familiar to me.
Backstory:
On my Webmin server, I have been trying to get a Drupal Installation to work. I changed a parameter on the MySQL module and now the MySQL will not start.
Current Situation:
When I click "Start MySQL Server" I receive the follow:
Failed to start database : Redirecting to /bin/systemctl start
mariadb.service Job for mariadb.service failed because the control
process exited with error code. See "systemctl status mariadb.service"
and "journalctl -xe" for details.
I've search around this, and most people recommend to reinstall MariaDB.
I connected to the server with putty to get some more information
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2017-08-01 16:29:00 UTC; 7min ago
Process: 22851 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=1/FAILURE)
Process: 22850 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS)
Process: 22823 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Main PID: 22850 (code=exited, status=0/SUCCESS)
Aug 01 16:28:57 li172-89.members.linode.com systemd[1]: Starting MariaDB database server...
Aug 01 16:28:57 li172-89.members.linode.com mysqld_safe[22850]: 170801 16:28:57 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Aug 01 16:28:57 li172-89.members.linode.com mysqld_safe[22850]: 170801 16:28:57 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Aug 01 16:29:00 li172-89.members.linode.com systemd[1]: mariadb.service: control process exited, code=exited status=1
Aug 01 16:29:00 li172-89.members.linode.com systemd[1]: Failed to start MariaDB database server.
Aug 01 16:29:00 li172-89.members.linode.com systemd[1]: Unit mariadb.service entered failed state.
Aug 01 16:29:00 li172-89.members.linode.com systemd[1]: mariadb.service failed.
[root#li172-89 ~]#
I gather that this means Mariadb wont even start so I should probably reinstall it. I did try to simply use a defaul my.cnf but that didn't really do anything.
Ideally, I do not want to lose any of the databases I have.
What should I do? Should I reinstall Mariadb? Is there a suitable guide that lists the commands? Could I install Mariadb but to another folder?
What is the best course of action at this point?