What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
A failed systemctl start mysqld command is only a symptom. The dependable fix is to preserve the service and journal output, read MySQL’s error log, then correct the specific resource named there: the data directory, a log or socket path, Unix permissions, an SELinux label or port rule, or a port already claimed by another process. Apply one narrow change, restart, and verify both the daemon and a local client connection.
Start with evidence, not repeated restarts
Run these commands as an administrator and save their output. Use the unit name installed on your system; Oracle MySQL packages commonly use mysqld, while MariaDB and some older or Software Collections packages may use a different name.
Free tools Windows power users keep installed
One-click scans. No signup required.
sudo systemctl status mysqld --no-pager -l
sudo journalctl -u mysqld -n 100 --no-pager
sudo journalctl -xe
The last command is useful when systemd directs you to the extended journal, but the unit-specific journal is usually easier to read. If mysqld does not exist, discover the installed unit instead of guessing:
systemctl list-unit-files --type=service | grep -Ei 'mysql|maria'
systemctl list-units --all --type=service | grep -Ei 'mysql|maria'
rpm -qa | grep -Ei 'mysql|mariadb'
Do not treat “Job for mysqld.service failed because the control process exited with error code” as the cause. It means the service process returned a failure; the journal and MySQL error log contain the useful message.
#1 Best Overall
Read the MySQL error log that the server is actually using
MySQL’s troubleshooting guidance is direct: check the error log to see why the server does not start. The log may be under the configured data directory, under /var/log, or at a path set by an option file. Read the newest entries, especially the final lines from the failed start.
sudo find /var/lib/mysql /var/log -maxdepth 3 -type f
( -iname '*err*' -o -iname '*error*' ) -ls 2>/dev/null
sudo tail -n 100 /path/to/mysql-error.log
Use the active configuration rather than assuming a default filename. Common option files include /etc/my.cnf and files in /etc/my.cnf.d/, but the package and release determine the exact layout.
sudo grep -RniE '^(datadir|socket|log-error|log_error|port|pid-file)'
/etc/my.cnf /etc/my.cnf.d 2>/dev/null
Record the exact error before changing anything. Messages such as Errcode: 13, “Permission denied,” “Can’t create/write to file,” “Can’t bind,” “Address already in use,” “Can’t connect to local server through socket,” or an SELinux AVC denial point to different repairs.
Confirm the active data directory and every dependent path
The server must know its data directory. MySQL uses it as the working location for databases and may also use it for logs and the PID file. A service can therefore fail even when the database files themselves are intact if the configured directory, a parent directory, a log directory, or a socket directory is missing.
- Read the configuration used by the service. Inspect the unit and its drop-ins as well as option files:
sudo systemctl cat mysqld sudo systemctl show mysqld -p ExecStart -p Environment sudo grep -RniE 'datadir|socket|log[-_]error|pid[-_]file|^port' /etc/my.cnf /etc/my.cnf.d 2>/dev/null - Check that each directory exists. Replace the examples with the paths shown in your configuration:
sudo ls -ld /var/lib/mysql /path/to/custom-datadir sudo ls -ld /path/to/log-directory /path/to/socket-directory sudo namei -l /path/to/custom-datadir - Check free space and read-only mounts.
df -hT mount | grep -E ' /var| /data|mysql' sudo touch /path/to/log-directory/.mysql-write-testRemove the test file after the check. A full filesystem, failed mount, or read-only volume must be fixed before MySQL can create its PID, socket, temporary, or log files.
If you moved /var/lib/mysql, verify that the new path contains the expected MySQL system tables and that the configuration points to it. Do not initialize a new data directory over an existing one; initialization can create an empty instance and obscure the original data.
Rank #2
Correct Unix ownership and permissions
MySQL’s documentation states that ownership and permissions on the data directory and its contents must allow the server to read and modify them. An Errcode 13 means “Permission denied”: the directory privileges or a file inside it do not permit server access.
First identify the service account from the unit or process configuration. It is often mysql, but do not assume:
sudo systemctl show mysqld -p User -p Group
getent passwd mysql
getent group mysql
Inspect both the top directory and the path components leading to it. The service needs execute (x) permission on every parent directory, not merely read/write permission on the final directory.
sudo stat -c '%A %U:%G %n' /var /var/lib /var/lib/mysql
sudo find /path/to/custom-datadir -maxdepth 2 -printf '%M %u:%g %pn' | head -n 100
For a data directory deliberately assigned to the mysql service account, a typical correction is:
sudo chown -R mysql:mysql /path/to/custom-datadir
sudo chmod 750 /path/to/custom-datadir
Use the permissions required by your distribution and security policy; do not blindly make database files world-readable or apply chmod -R 777. Check log, socket, and PID directories separately, because they may intentionally have different owners or modes. Never run the database as root as a routine permissions workaround. If ownership is already correct, stop changing it and investigate SELinux, the path, or a conflicting process.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Check SELinux when the path is non-default
Unix mode bits can look correct while SELinux still blocks mysqld. This is especially common after moving the data directory or placing logs and sockets outside the distribution’s defaults. Check the enforcement state and recent audit records:
getenforce
sudo ausearch -m avc -ts recent
sudo grep -i denied /var/log/audit/audit.log | tail -n 50
sudo ls -Zd /var/lib/mysql /path/to/custom-datadir
On SELinux-enabled RHEL-family systems, the default MySQL data directory /var/lib/mysql/ is associated with the mysqld_db_t file context. A custom directory normally needs a persistent equivalent label under the policy installed on that host. Where the management utility is available, inspect existing rules:
sudo semanage fcontext -l | grep -i mysql
Then add a rule for the custom tree and restore labels. The exact policy may distinguish database files from logs, so use the type already assigned to the corresponding default resource on your release:
sudo semanage fcontext -a -t mysqld_db_t '/path/to/custom-datadir(/.*)?'
sudo restorecon -Rv /path/to/custom-datadir
sudo ls -Zd /path/to/custom-datadir
If semanage is missing, install the distribution package that provides it according to your CentOS release, or use the policy-supported method documented for that release. Do not leave the whole machine in permissive mode as a permanent fix. A temporary permissive test can change the diagnosis while exposing the database to avoidable risk; use the AVC record to create the narrow label or policy correction instead.
Allow a non-default MySQL port in SELinux
The default MySQL TCP port documented by Oracle is 3306. If the configuration uses another port, two independent checks are required: determine whether the port is free, and ensure SELinux permits mysqld to bind it.
Rank #4
sudo grep -RniE '^port[[:space:]]*=' /etc/my.cnf /etc/my.cnf.d 2>/dev/null
sudo semanage port -l | grep mysqld_port_t
sudo semanage port -a -t mysqld_port_t -p tcp 3307
Use -m instead of -a when that port is already defined with a different type. Substitute the configured port for 3307. Oracle documents that a non-default port such as 3307 can fail with an AVC name_bind denial when the SELinux policy is not updated.
Find port, socket, and duplicate-process conflicts
Another mysqld instance, a MariaDB service, or an unrelated application may already own the configured TCP port. Check the configured value, not just the default:
sudo ss -ltnp | grep -E ':3306b|:3307b'
sudo lsof -nP -iTCP:3306 -sTCP:LISTEN
sudo ss -lxnp | grep -i mysql
For a Unix-socket error, inspect the configured socket path and its parent directory. A stale socket file can mislead clients, but deleting it while a live server owns the socket is unsafe. First determine whether a process is running:
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →pgrep -a mysqld
sudo systemctl status mysqld
sudo ls -l /path/to/mysql.sock
If a second database service is listening, stop or reconfigure the unintended service through systemd rather than killing processes at random. If a previous process is genuinely orphaned, capture its command line and status, stop it cleanly where possible, and only then remove a stale PID or socket file when the error log confirms that no server owns it.
Apply the smallest correction and verify the result
After correcting the resource named by the evidence, restart the installed unit and immediately repeat the checks. Do not assume that a successful systemd transaction means clients can connect.
Best Value
sudo systemctl restart mysqld
sudo systemctl status mysqld --no-pager -l
sudo journalctl -u mysqld -n 100 --no-pager
sudo tail -n 100 /path/to/mysql-error.log
sudo ss -ltnp | grep -E ':3306b|:3307b'
Test the local socket or configured TCP port with a client using the same endpoint your application uses:
mysqladmin --protocol=socket --socket=/path/to/mysql.sock ping
mysqladmin --protocol=tcp --host=127.0.0.1 --port=3306 ping
A healthy result is a running service, a new error-log entry showing successful readiness, a listening socket or port, and a local client response such as mysqld is alive. Keep the before-and-after status, journal, and log output so a rollback or escalation has a precise record.
Recommended Free Tools
Use the error message to choose the branch
| Observed symptom | Resource to inspect | Targeted action |
|---|---|---|
Errcode: 13 or “Permission denied” |
Data directory, parent directories, log and PID paths; Unix owner and mode | Identify the service account, correct ownership/modes, then check SELinux labels if the denial remains |
| “Can’t create/write” a file | The named file’s parent directory, free space, mount state, and SELinux context | Create the directory if appropriate, grant the service account access, and restore the policy context |
| “Address already in use” | Configured TCP port or Unix socket | Find the owning process with ss/lsof; stop or reconfigure the conflicting service, or choose a documented free port |
AVC name_bind on a changed port |
SELinux port policy | Assign the configured TCP port the mysqld_port_t type with semanage |
| AVC denial after moving the data directory | SELinux file context on the custom tree | Add a persistent file-context rule and run restorecon; verify with ls -Z |
| Socket connection failure while no listener exists | Socket path, parent permissions, and whether startup completed | Read the error log first; fix startup, then align the client’s socket setting with the server’s configured path |
| Systemd reports only an exit code | Unit-specific journal and MySQL error log | Do not repair from the exit code alone; locate the final MySQL error and follow its resource-specific branch |
Common CentOS scenarios
After moving /var/lib/mysql
Confirm that the new directory is mounted at boot, contains the original database files, is configured as datadir, is owned by the service account, and has the expected SELinux type. Red Hat documents startup failures on SELinux-enabled systems when the data directory is moved without correcting its file context. Fix the mount and context before attempting initialization.
After changing the port
Confirm that the new port is present in the active configuration, unused by another process, permitted by SELinux, and reflected in local client and application settings. A server that binds successfully on a new port will still appear “down” to clients that continue to use 3306.
After installing MariaDB or a nonstandard package
Service names, option-file locations, default paths, and SELinux policy details vary by CentOS/RHEL release and by whether Oracle MySQL, MariaDB, or a Software Collections package is installed. Identify the package and unit first, then substitute that unit in every command. Do not copy a mysqld path or service name from another installation without checking.
When the server still will not start
- Preserve the complete failed-start journal and the final error-log lines before another attempt changes the evidence.
- Check every path in the error, including parent-directory execute permission, not just the data directory.
- Compare the configured data directory, socket, log, PID file, and port with the paths your client and service actually use.
- Check for disk-full conditions, failed mounts, read-only filesystems, and a second database process.
- Review recent SELinux AVC records whenever a path or port is non-default, even when Unix ownership appears correct.
- Avoid destructive actions: do not initialize an existing data directory, delete unknown database files, or run
chmod -R 777.
Escalation is appropriate when the log indicates damaged InnoDB or system tables, missing files, failed storage, or an upgrade incompatibility rather than a service-account, path, port, or policy problem. At that point, preserve the data directory and logs and use a tested recovery or backup procedure instead of repeatedly starting the service.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsQuick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

