systemctl start
and systemctl enable
do different things.
enable
will hook the specified unit into relevant places, so that it will automatically start on boot, or when relevant hardware is plugged in, or other situations depending on what's specified in the unit file.
start
starts the unit right now.
disable
and stop
are the opposite of these, respectively.
This means that when you first install MariaDB, you might want to run systemctl enable mariadb.service
to enable it so it starts on boot. You might also want to run systemctl start mariadb.service
, or just reboot, in order to start MariaDB. To stop MariaDB, run systemctl stop mariadb.service
(it will start again on next boot or when you manually start it). To disable it so it doesn't start on boot anymore, run systemctl disable mariadb.service
.
Update:
As noted in gerardw's answer, starting from version 220, released in may 2015, both enable
and disable
started to take the optional --now
switch in order to also start or stop the unit, depending on the used command.
To both disable and stop a unit with the same command, use systemctl disable mariadb.service --now
. Similarly, to both enable and start a unit, use systemctl enable mariadb.service --now
.
Source: systemctl man page
enable
andstart
with the--now
swich ofenable
subcommand, eg:systemctl enable sshd --now
. The same is true fordisable
command to alsostop
the service.