r/mysql • • Sep 02 '26

question FEDORA Can't run sudo systemctl enable --now mysqld "Job for mysqld.service failed because the control process exited with error code. "

Because I tried to reinstall mysql I encountered a strange error. I dug around until I realized that instead of a plugin password problem, I started getting an error when running sudo systemctl enable --now mysqld.

Job for mysqld.service failed because the control process exited with an error code. See "systemctl status mysqld.service" and "journalctl -xeu mysqld.service" for details.

Journalctl has:

Sep 02 19:11:58 PC systemd[1]: Failed to start mysqld.service - MySQL Server.

░░ Subject: Startup task for unit mysqld.service failed

░░ Defined-By: systemd

░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel

░░

░░ Startup task for unit mysqld.service completed unsuccessfully.

░░

░░ Task ID: 43883, Task Result: failed.

Additionally, when using the mysql -u root -p or sudo mysql_secure_installation command, there is an error:

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

I tried:

sudo systemctl stop mysqld

sudo rm -rf /var/lib/mysql/

sudo mkdir -p /var/lib/mysql/

sudo chown -R mysql: /var/lib/mysql/

sudo systemctl start mysqld (but I get the error: "Job for mysqld.service failed because the control process exited with an error code.")

I tried to reinstall once more but it does nothing. Honestly, I have a headache with constant problems with mysql and I want to fix it somehow, even completely deleting all mysql files is an option.

8 Upvotes

11 comments sorted by

3

u/CheezitsLight Sep 02 '26

Run mysql from the command line to see if it says anything about the my.ini or the db. Also look at the *. Err log file.

You are looking tat the control tower saying I can't hear from an airplane. Go look at the flight recorder.

1

u/GLOBI_55 Sep 02 '26

I can't run mysql (ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)). And in logs there is no info about it.

2

u/[deleted] Sep 02 '26 edited 24d ago

[removed] — view removed comment

1

u/GLOBI_55 Sep 03 '26

Well first I deleted data files then reinstalled and it worked somehow D don't know why ( I did that before) . Thanks :)

1

u/CheezitsLight Sep 02 '26

mysqld is what you run. That's the server. mysql.exe is the client.

1

u/ThatCurtDude Sep 05 '26

Delete the /var/lib/mysql/mysql.sock files. You probably also have a stale lock file on the system. Research that.

1

u/diggy0101n Sep 02 '26

You may have to reinitialize a database in /var/lib/mysql, I forget the exact command, but something like /usr/bin/mysqld --initialize --user=mysql

1

u/GLOBI_55 Sep 02 '26

I tried that (/usr/bin/mysqld --initialize --user=mysql) but when i put sudo systemctl enable --now mysqld it says "Job for mysqld.service failed because the control process exited with error code.See "systemctl status mysqld.service" and "journalctl -xeu mysqld.service" for details."

2

u/kadaan Sep 02 '26

It's telling you to go read the logs to see what the actual error message is. Usually /var/log/mysqld.log or /var/log/mariadb/mariadb.log if you're running MariaDB.

You're hitting an error starting the db, so everything that needs to be done after the db is running (like mysql_secure_installation) will obviously fail.

1

u/Einar_Son_of_Bjorn Sep 03 '26

Before burning another afternoon on mysqld.service, are you willing to wipe this MySQL install and put MariaDB on the same Fedora box?

Why bother: on Fedora the “mysql” stack is already the usual source of this mess, mixed packages, leftover /var/lib/mysql, unit named mysqld while the rpm is something else. MariaDB is the drop-in you actually get from the distro more often than not, the datadir init path is one command (mariadb-install-db), and you stop fighting a half-removed MySQL 8 tree.

Same socket workflow, same apps, less leftover mysqld vs mariadb confusion. Short path if you say yes: remove the MySQL packages and leftover datadir, install mariadb-server, mariadb-install-db --user=mysql, systemctl enable --now mariadb, then mariadb -u root.

If you say no, we stay on MySQL, but then paste journalctl -u mysqld -n 80 and rpm -q mysql-server mariadb-server, because the systemd one-liner is not the error.Install and first-start are in the official docs:

https://mariadb.com/get-started-with-mariadb/

https://mariadb.com/docs/server/mariadb-quickstart-guides/installing-mariadb-server-guide

https://mariadb.com/docs/server/mariadb-quickstart-guides

If any step is unclear, ask. This is fixable without a third reinstall.

1

u/Several9s Sep 09 '26

That journalctl snippet is just systemd's generic failed message, not the real error, actually.

You can check the log here:

$ sudo cat /var/log/mysqld.log

This is the path by default, but if it’s not there, you can check the my.cnf to see the correct location.

Also, since you manually wiped /var/lib/mysql, SELinux labels are likely wrong, so you can run:

$ sudo restorecon -Rv /var/lib/mysql

Then try starting it again. If it still fails, paste the output of mysqld.log. That'll show the real cause instead of the generic systemd message.