To facilitate a non root user, e.g. the mysql OS user, to stop and start MySQL Server using OS level system administration tools which rely on Systemd. The following entry in the sudoers file will allow the OS user mysql to stop and start the mysql server via the OS administration wrapper.
# visudo ## MySQL Admin Cmnd_Alias MYSQLADMIN = /usr/bin/systemctl stop mysqld, /usr/bin/systemctl start mysqld,/usr/bin/systemctl restart mysqld mysql ALL=MYSQLADMIN
As the mysql OS user , the Service can now be stopped / started as expected.
$ sudo systemctl stop mysqld $ systemctl status mysqld ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: inactive (dead) since Mon 2016-06-06 12:34:28 AEST; 1s ago Process: 11633 ExecStart=/usr/sbin/mysqld --daemonize $MYSQLD_OPTS (code=exited, status=0/SUCCESS) Process: 11617 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 11637 (code=exited, status=0/SUCCESS)
$ sudo systemctl start mysqld $ systemctl status mysqld ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2016-06-06 12:34:38 AEST; 1s ago Process: 11697 ExecStart=/usr/sbin/mysqld --daemonize $MYSQLD_OPTS (code=exited, status=0/SUCCESS) Process: 11682 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 11701 (mysqld) CGroup: /system.slice/mysqld.service └─11701 /usr/sbin/mysqld --daemonize
Note: MySQL 5.6 does not natively use the systemd wrappers, even on supported OSes. It will still use the SysV scripts, typically in /etc/init.d. These can be stopped/started without any special privileges. Special attention is required, however, if the DB is scheduled to start on system boot, as in this scenario, root file permissions may exist on, eg lock file/error log.