Preface
In daily operation and maintenance, MySQL, as a widely used relational database, its stability and availability are crucial. However, sometimes the MySQL service may fail to start after a system upgrade or configuration change. This article conducts in-depth analysis and processing of a certain actual case, mainly focusing on log errors when the MySQL 5.7 service start failed to run 'start-pre' task: Operation not supported, combining the problem investigation and resolution process to provide detailed analysis and steps.
1. Problem background
A server is running well. When the user restarts the MySQL database server after system upgrade and maintenance, the service starts fail. Execute the commandsystemctl start mysqld
After that, the error message is as follows:
11 27 15:44:44 systemd[1]: failed to run 'start-pre' task: Operation not supported 11 27 15:44:44 systemd[1]: Failed to start MySQL Server. 11 27 15:44:44 systemd[1]: Unit entered failed state. 11 27 15:44:44 systemd[1]: failed. 11 27 15:44:44 systemd[1]: Starting MySQL Server...
From the log information,In the start-up preprocessing stage (
start-pre
) failed, causing the service to fail to start. The problems in this case mainly focus on errors occurring when systemd starts MySQL service, while manual startup of the service can run successfully, indicating that there may be system environment, configuration or permissions issues.
2. Error analysis
2.1 Detailed explanation of error information
From the error message in the log, the following key points can be extracted:
failed to run 'start-pre' task: Operation not supported
Indicates that the execution of preprocessing tasks failed during the MySQL service startup process managed by systemd.start-pre
The stage usually performs some initialization tasks, such as checking configuration files, creating run directories, or setting file permissions.Failed to start MySQL Server
andentered failed state
It means that the MySQL service has entered a failed state and cannot start normally.
2.2 Possible Causes
Combining error information and service characteristics, the possible reasons are analyzed as follows:
Configuration file issues
MySQL configuration files (such as/etc/
) There may be syntax errors, incompatible configurations, or some parameters are unavailable due to upgrades.Permissions issues
MySQL data directory (such as/var/lib/mysql
) or the relevant log file permissions are incorrectly set, which may prevent the MySQL service from accessing these resources normally.Dependency package issue
After the system is upgraded, the dependency packages or modules required for the MySQL service may be missing.Systemd configuration issues
The file may be corrupted due to the upgrade, or some configurations are incompatible with the current system version.
Kernel or system issues
If a system upgrade involves kernel changes, some features may no longer support the current MySQL service.
3. Problem troubleshooting and solutions
3.1 Check MySQL Error Log
First check out MySQL's detailed error log for more clues:
sudo cat /var/log/
If there is no key information in the error log, you can passjournalctl
View the systemd log:
sudo journalctl -u
After analyzing the log, if you find a clear cause of the error, you can fix it in a targeted manner. For example, if a prompt is invalid, you can modify the MySQL configuration file.
3.2 Verify MySQL configuration file
MySQL configuration file errors are one of the common problems. Verify the correctness of the configuration file with the following command:
mysqld --validate-config
If you find a configuration error (such as an invalid parameter or a wrong path), modify the configuration file according to the prompt./etc/
or other related configurations. Here are the checkpoints for common questions:
- Data directory path
datadir
Whether it is correct. - Log file path (such as
log-error
) Whether it exists. - Whether there are any parameters that are deprecated after upgrading.
Save the configuration file after modification and try to start the MySQL service again.
3.3 Check file and directory permissions
The MySQL service startup requires access to multiple key files and directories, including data directories, log directories, etc. You can check and fix permission issues:
sudo chown -R mysql:mysql /var/lib/mysql sudo chmod -R 755 /var/lib/mysql
If you use a custom data directory, you need to adjust the above commands according to the actual path.
Check at the same time/etc/
So if the configuration file has sufficient read permission:
sudo chmod 644 /etc/
3.4 Start MySQL service manually
To further locate the problem, you can bypass systemd and run MySQL manually:
sudo -u mysql mysqld --defaults-file=/etc/ --datadir=/var/lib/mysql &
If the manual startup is successful, it means that there is no problem with MySQL itself, and the problem may be in the systemd configuration or permissions.
3.5 Fix the systemd configuration file
Check and repair files, usually located in /usr/lib/systemd/system/ or /etc/systemd/system/. Make sure the file content is correct, for example:
[Unit] Description=MySQL Server After= [Service] User=mysql Group=mysql ExecStart=/usr/sbin/mysqld --defaults-file=/etc/ LimitNOFILE=5000 Restart=on-failure [Install] WantedBy=
After modification, reload the systemd configuration and start the service:
sudo systemctl daemon-reload sudo systemctl start mysqld
3.6 Verify the dependent environment
Check whether the MySQL dependent libraries and tools in the system are complete. For example:
sudo yum install -y mysql-libs
If the system upgrade causes some dependency packages to be deleted, the required packages can be reinstalled.
4. Further optimization and automation processing
To avoid similar problems from happening again, the following optimizations can be performed:
Regularly backup configuration and service files
Before upgrading the system, backup/etc/
、/usr/lib/systemd/system/
and other key documents.Enable automatic recovery mechanism
Using systemdRestart=on-failure
Parameters to ensure that the MySQL service automatically restarts in unexpected failures.Build a startup script
Create a script for MySQL that starts MySQL with manual commands when system starts.
Conclusion
Through detailed analysis and step-by-step troubleshooting, this article has solved the problem failed to run 'start-pre' task: Operation not supported
The problem. The root cause of the problem may involve configuration files, permissions, systemd configuration, or system environment. By checking logs, repairing configurations, and adjusting permissions, the MySQL service was finally restored to normal operation. I hope that the experience and methods provided in this article can help other users who encounter similar problems.
The above is the MySQL startup failure error report: failed to run ‘start-pre’ task problem analysis and solution details. For more information about MySQL startup error report, please pay attention to my other related articles!