Urgent Help Needed: MySQL Removed on Ubuntu 22 Server

Hello everyone,

I’m facing a critical issue with my Ubuntu 22 server running the Hestia Control Panel. Unfortunately, due to a series of accidental commands executed by a friend, the MySQL service seems to have been removed or damaged.

As a result, any attempts to create a database or interact with MySQL result in the error message: “Error: Connection to localhost failed”.

Could someone kindly provide guidance on how I can restore MySQL or troubleshoot this problem effectively? Any step-by-step instructions or advice would be greatly appreciated.

Thank you in advance for your assistance.

Server Details:

Operating System: Ubuntu 22
Control Panel: Hestia Control Panel

Can you login the server and check the mysql directory, if all the created databases are in there?

If yes, then you may have only connection problems and may not need to reinstall the server.

In this case, you may be lucky that this problem can be solved with little effort.

I can log in without any issues. I’m not sure if this is just luck or not, but I haven’t created any databases yet.

  1. Check first if you have still backups of the databases that are made via Hestai
  2. Check /var/lib/mysql exists and if so create a backup of it
  3. apt install mysql-server should reinstall it

Then modify /usr/local/hestia/conf/mysql.conf with the new password

And restore the backups from Hestia backups or copy over the backup /var/lib/mysql folder to the new /var/lib/mysql folder

This is the output of the install command, indicating that it’s installed. However, I suspect it’s not functioning properly, and I don’t have the password for it.

sudo apt install mysql-server
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
mysql-server is already the newest version (8.0.36-0ubuntu0.22.04.1).
The following packages were automatically installed and are no longer required:
  galera-4 libconfig-inifiles-perl libdaxctl1 libndctl6 libpmem1 libpq5 libterm-readkey-perl liburing2
  linux-image-5.4.0-105-generic linux-modules-5.4.0-105-generic pv socat
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
1 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 exim4-daemon-light (4.95-4ubuntu2.5) ...
Job for exim4.service failed because the control process exited with error code.
See "systemctl status exim4.service" and "journalctl -xeu exim4.service" for details.
invoke-rc.d: initscript exim4, action "start" failed.
× exim4.service - LSB: exim Mail Transport Agent
     Loaded: loaded (/etc/init.d/exim4; generated)
     Active: failed (Result: exit-code) since Tue 2024-05-07 16:51:42 CEST; 17ms ago
       Docs: man:systemd-sysv-generator(8)
    Process: 121001 ExecStart=/etc/init.d/exim4 start (code=exited, status=1/FAILURE)
        CPU: 625ms

May 07 16:51:42 vmi1656013.contaboserver.net systemd[1]: Starting LSB: exim Mail Transport Agent...
May 07 16:51:42 vmi1656013.contaboserver.net exim4[121001]:  * Starting MTA
May 07 16:51:42 vmi1656013.contaboserver.net exim4[121244]: 2024-05-07 16:51:42 Exim configuration error in line 48 of /var/lib/exim4/config.autogenerated.tmp:
May 07 16:51:42 vmi1656013.contaboserver.net exim4[121244]:   main option "acl_smtp_mime" unknown
May 07 16:51:42 vmi1656013.contaboserver.net exim4[121246]: Invalid new configfile /var/lib/exim4/config.autogenerated.tmp, not installing
May 07 16:51:42 vmi1656013.contaboserver.net exim4[121246]: /var/lib/exim4/config.autogenerated.tmp to /var/lib/exim4/config.autogenerated
May 07 16:51:42 vmi1656013.contaboserver.net systemd[1]: exim4.service: Control process exited, code=exited, status=1/FAILURE
May 07 16:51:42 vmi1656013.contaboserver.net systemd[1]: exim4.service: Failed with result 'exit-code'.
May 07 16:51:42 vmi1656013.contaboserver.net systemd[1]: Failed to start LSB: exim Mail Transport Agent.
dpkg: error processing package exim4-daemon-light (--configure):
 installed exim4-daemon-light package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 exim4-daemon-light
E: Sub-process /usr/bin/dpkg returned an error code (1)

There are more things wrong then only mysql server …

Indeed, it appears that MySQL is presenting several issues.

But didn’t you have MariaDB? Have you tried reinstalling that?

You should have the root password in this file /root/.my.cnf

If you want to reinstall mysql-server use apt reinstall command:

Warning: before reinstall mysql, you should make sure you have a backup of /var/lib/mysql/ and /etc/mysql/ because you at least should replace the conf in /etc/mysql/ dir.

apt reinstall mysql-server

The error you get with exim is because you installed the wrong package exim4-daemon-light and you should install the package exim4-daemon-heavy Once the package is installed, maybe you should restore a backup of /etc/exim4/exim4.conf.template Anyway, remember to backup /etc/exim4/ before installing the right package.

It would be interesting to know what your friend did, maybe the commands your friend used are still in the history of root or the user your friend used to break your server.

Sometimes it is easier to clean all and start a fresh install and restore your user’s data from backups.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.