MySQL Forums
Forum List  »  Install & Repo

unable to start mysqld.service but command line works
Posted by: James Preston
Date: October 07, 2024 01:46AM

I have been beating my head against this problem and can't find the solution. When I run systemctl start mysqld.service the mysql server fails to start with the following from journalctl -xeu mysqld.service:


$ journalctl -xeu mysqld.service ░░ Subject: A start job for unit mysqld.service has begun execution
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit mysqld.service has begun execution.
░░
░░ The job identifier is 62403.
Oct 06 21:18:15 jimfedoranew.prestoncomputerservice.com mysqld[54841]: 2024-10-07T04:18:14.805170Z 0 [System] [MY-015015] [Server] MySQL Server - start.
Oct 06 21:18:15 jimfedoranew.prestoncomputerservice.com mysqld[54841]: 2024-10-07T04:18:15.677007Z 0 [Warning] [MY-010091] [Server] Can't create test file /us>
Oct 06 21:18:15 jimfedoranew.prestoncomputerservice.com mysqld[54841]: 2024-10-07T04:18:15.677320Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.>
Oct 06 21:18:15 jimfedoranew.prestoncomputerservice.com mysqld[54841]: 2024-10-07T04:18:15.690841Z 0 [Warning] [MY-010091] [Server] Can't create test file /us>
Oct 06 21:18:15 jimfedoranew.prestoncomputerservice.com mysqld[54841]: 2024-10-07T04:18:15.690869Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_n>
Oct 06 21:18:15 jimfedoranew.prestoncomputerservice.com mysqld[54841]: 2024-10-07T04:18:15.728093Z 0 [ERROR] [MY-010187] [Server] Could not open file '/usr/lo>
Oct 06 21:18:15 jimfedoranew.prestoncomputerservice.com systemd[1]: mysqld.service: Got notification message from PID 54841, but reception only permitted for >
Oct 06 21:18:15 jimfedoranew.prestoncomputerservice.com systemd[1]: mysqld.service: Got notification message from PID 54841, but reception only permitted for >
Oct 06 21:18:15 jimfedoranew.prestoncomputerservice.com mysqld[54839]: 2024-10-07T04:18:15.765776Z 0 [ERROR] [MY-010946] [Server] Failed to start mysqld daemo>
Oct 06 21:18:15 jimfedoranew.prestoncomputerservice.com systemd[1]: mysqld.service: Got notification message from PID 54841, but reception only permitted for >
Oct 06 21:18:15 jimfedoranew.prestoncomputerservice.com systemd[1]: mysqld.service: Got notification message from PID 54841, but reception only permitted for >
Oct 06 21:18:15 jimfedoranew.prestoncomputerservice.com mysqld[54841]: 2024-10-07T04:18:15.729006Z 0 [ERROR] [MY-010119] [Server] Aborting
Oct 06 21:18:15 jimfedoranew.prestoncomputerservice.com mysqld[54841]: 2024-10-07T04:18:15.795988Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown >
Oct 06 21:18:15 jimfedoranew.prestoncomputerservice.com mysqld[54841]: 2024-10-07T04:18:15.796016Z 0 [System] [MY-015016] [Server] MySQL Server - end.
Oct 06 21:18:15 jimfedoranew.prestoncomputerservice.com systemd[1]: mysqld.service: Main process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ An ExecStart= process belonging to unit mysqld.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 1.
Oct 06 21:18:15 jimfedoranew.prestoncomputerservice.com systemd[1]: mysqld.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ The unit mysqld.service has entered the 'failed' state with result 'exit-code'.
Oct 06 21:18:15 jimfedoranew.prestoncomputerservice.com systemd[1]: Failed to start mysqld.service - MySQL Server Documentation=man:mysqld(8).
░░ Subject: A start job for unit mysqld.service has failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit mysqld.service has finished with a failure.
░░
░░ The job identifier is 62403 and the job result is failed.
Oct 06 21:18:15 jimfedoranew.prestoncomputerservice.com systemd[1]: mysqld.service: Consumed 1.201s CPU time.
░░ Subject: Resources consumed by unit runtime
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ The unit mysqld.service completed and consumed the indicated resources.
lines 674-722/722 (END)


The data directory is owned by mysql, group is mysql, user is member of mysql

Here is mysqld.service:

cat /usr/lib/systemd/system/mysqld.service
[Unit]
Description=MySQL Server Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
user=mysql
group=mysql
# Have mysqld write its state to the systemd notify socket
Type=notify
# Disable service start and stop timeout logic of systemd for mysqld
# service.
TimeoutSec=0
# Start main service
ExecStart=mysqld --defaults-file=/etc/my.cnf
$MYSQLD_OPTS
# Use this to switch malloc implementation
EnvironmentFile=-/etc/sysconfig/mysql
# Sets open_files_limit
LimitNOFILE = 10000 Restart=on-failure RestartPreventExitStatus=1
# Set environment variable MYSQLD_PARENT_PID. This is required for
# restart.
Environment=MYSQLD_PARENT_PID=1
PrivateTmp=false

Here is /etc/my.cnf:

cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.4/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
port=3306
log-error=/usr/local/mysql/data/localhost.err
pid-file=/usr/local/mysql/data/mysqld.pid
user=mysql
secure_file_priv=/usr/local/mysql/mysql-files
local_infile=off

[mysql]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
port=3306
yet if I log in with root (or su) and run mysqld from command line server runs and writes to the data directory (/usr/local/mysql/data)

$ su
Password:
root# mysqld -u mysql -D
mysqld will log errors to /usr/local/mysql/data/localhost.err
mysqld is running as pid 60011

root# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.4.2 MySQL Community Server - GPL

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Any pointers would be greatly appreciated. I figure it has to be something simple, but I do not want to do a chmod 777 on the data directory just to make systemd happy.

Options: ReplyQuote




Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.