Home / Alt manpages / mysqld(8)

  • mysqld(8)
  • Admin command
  • linux

Operate MariaDB Safely Through mysqld on Ubuntu

This guide gets you from an installed mysqld command to a checked MariaDB service: you will identify the binary and version, inspect the options it would use, and control the existing systemd service without accidentally launching a second database server. It covers the Ubuntu package found here, MariaDB 10.11.14, where mysqld is a symlink to mariadbd.

Allow about 10 minutes. You need a shell account, sudo for service changes, and the mariadb-server-core package. The inspection commands are ordinary user commands. Starting, stopping, enabling or restarting the service changes system state and needs elevated privileges.

1. Confirm what mysqld means on this host

The short manpage is an entry point, not a complete server reference. Both local pages describe the same role: MariaDB Server manages the data directory, listens for client connections, and accepts startup options. The installed executable is named mariadbd; the traditional mysqld name remains available as an alias.

command -v mysqld
readlink -f "$(command -v mysqld)"
mysqld --version
man mysqld

On the package used for this guide, the version check reports MariaDB 10.11.14 for Debian Linux on x86_64. Your output may differ after an update, so keep the reported version with any support ticket or change record.

Checkpoint: the name is settled

Continue when mysqld --version identifies MariaDB and the resolved path points to the installed server binary. If the command is missing, stop here and install or repair the server package through your normal package-management process. Do not download an unrelated binary into /usr/local/bin just to satisfy an old command name.

2. Inspect the effective startup view

Before changing a configuration file, ask the server what it reads. The verbose help output lists the default option files, the option groups, and the compiled defaults that the executable can report. The exact order matters: later option-file settings can override earlier ones.

mysqld --verbose --help 2>/tmp/mysqld-help.txt | less
mysqld --print-defaults
mysqld --verbose --help 2>&1 | grep -E '^(datadir|log-error)[[:space:]]'

The first command is deliberately read-only, but it can print a large amount of text. The temporary file is only a convenience for this shell session; remove it when you have finished reviewing it:

rm -f /tmp/mysqld-help.txt

--print-defaults displays the arguments assembled from option files and exits without starting the server. It is useful for spotting an unexpected --datadir, socket, port or log setting. Treat the output as sensitive operational information: configuration may contain paths or connection details, and it can expose mistakes in a file that you did not realise was being loaded.

3. Find the option file before editing it

MariaDB reads the normal global files and the account-level file shown by the help output. Package layouts vary, so inspect the files that actually exist rather than assuming that one particular path is authoritative.

ls -l /etc/my.cnf /etc/mysql/my.cnf "$HOME/.my.cnf" 2>/dev/null
find /etc/mysql -maxdepth 2 -type f -name '*.cnf' -print 2>/dev/null

For a one-off test with a separate configuration, use --defaults-file as the first argument. That option selects only the named file; it does not merge the usual files. The file must already exist. Do not point it at the production configuration while experimenting with a different data directory.

test -r /etc/mysql/my.cnf && mysqld --defaults-file=/etc/mysql/my.cnf --print-defaults

Keep changes in the option group intended for the server, such as [mysqld] or [mariadbd]. A setting in a client-only group will not configure the daemon. Make a dated backup before an edit, then validate the resulting options with --print-defaults before restarting anything.

sudo cp -p /etc/mysql/mariadb.conf.d/50-server.cnf /etc/mysql/mariadb.conf.d/50-server.cnf.bak.$(date +%Y%m%d%H%M%S)
sudoedit /etc/mysql/mariadb.conf.d/50-server.cnf
sudo mysqld --print-defaults

The backup command is an example only: replace the source path with the file you verified in the preceding step. Recovery is to copy the matching .bak. file back into place, then restart the service only after checking the restored options.

Checkpoint: configuration is explainable

You should now be able to name the data directory, the error-log destination and the file that supplies each setting you plan to change. If --print-defaults prints an unexpected option, pause and trace the include chain. A common distraction is editing one file while an included directory or later file wins.

4. Use systemd for the running service

On current Ubuntu releases the packaged service is mariadb.service. Check it before taking action:

systemctl is-active mariadb.service
systemctl is-enabled mariadb.service
sudo systemctl status mariadb.service --no-pager

inactive and disabled are different facts: the first describes its current process state, while the second says it is not configured to start automatically. A failed service needs its journal and MariaDB error log, not repeated start attempts.

sudo journalctl -u mariadb.service -b --no-pager -n 80

Starting the service is disruptive if applications expect it to remain stopped, so check the change window first. When it is approved, start the packaged unit rather than running mysqld directly:

sudo systemctl start mariadb.service
sudo systemctl is-active mariadb.service
sudo systemctl status mariadb.service --no-pager

Expected success is an active result and a status line similar to Active: active (running). If it fails, read the journal before changing files. Common causes include a wrong data-directory path, permissions that do not allow the MariaDB service account to read or write its files, a port already in use, or a malformed option.

5. Stop, restart and undo deliberately

Stopping disconnects clients and restarting briefly interrupts service. Use the narrowest action that matches the change:

  • Use start when the service is stopped.
  • Use restart after a configuration change that requires a new process.
  • Use stop only when you intend to take the database offline.
  • Use enable or disable only when changing boot behaviour, not merely to start or stop it now.
sudo systemctl restart mariadb.service
sudo systemctl is-active mariadb.service

If the restart exposes a bad edit, restore the backup made before the change and inspect it again:

sudo cp -p /etc/mysql/mariadb.conf.d/50-server.cnf.bak.YYYYMMDDHHMMSS /etc/mysql/mariadb.conf.d/50-server.cnf
sudo mysqld --print-defaults
sudo systemctl restart mariadb.service

Replace the dated suffix with the exact backup name. Do not delete the only backup until the service has started cleanly and the application has passed its own health checks.

Done means

  • mysqld --version identifies the expected MariaDB release.
  • mysqld --print-defaults produces an explainable option list.
  • You know which option file and group supplies each change.
  • systemctl is-active mariadb.service reports the intended state.
  • A configuration backup exists before any service-disrupting edit.