I'm following instructions on vultr to install LAMP stack on VPS (https://www.vultr.com/docs/how-to-install-apache-mysql-and-php-on-ubuntu-16-04). When trying to enable mysql on boot I'm getting an error.

# sudo systemctl enable mysql.service
Synchronizing state of mysql.service with SysV service script with 
Executing: /lib/systemd/systemd-sysv-install enable mysql
Failed to enable unit: Refusing to operate on linked unit file 

I'm a bit new to setting up a VPS so any help would be amazing.


Try sudo systemctl enable mariadb.service

because mysql.service is a sym link to mariadb.service

  • The system is trying to create mysql.service symlink so that the stack can talk to the database under that name. What's running under that name may well be mariadb. Your solution does not create the needed symlink. How will the rest of the stack be able to contact mysql.service? It won't be running. Instead mariadb will. His results could be caused by mysql.service being already enabled (with symlink pointed to whatever db is already configured on the machine.) – Xalorous Dec 20 '18 at 19:35
  • thanks for the feedback, I'm not a specialist and actually I had the exact same issue as Chris. I gave that reply because that exact behavior fixed it for me at least. As to your remark, I've just tested whether or not the symbolic link for mysql is created when running systemctl enable mariadb.service. On my system (Ubuntu 18.04.1 LTS) 2 symbolic links pointing to mariadb.service are automatically created: mysql.service and mysqld.service. – 8ctopus Dec 24 '18 at 13:46
  • Failed to enable unit: Unit file mariadb.service does not exist. – Aaron Franke Sep 19 '20 at 2:41
  • @AaronFranke try ls -l /etc/systemd/system do you see any symbolic links to /lib/systemd/system/mariadb.service? – 8ctopus Sep 23 '20 at 4:17

mysql.service may already be partially enabled, try

sudo systemctl disable mysql.service

sudo systemctl enable mysql.service
  • 2
    Especially true when you switch from mariadb to percona-xtradb for example. It was linked to the wrong package. Thanks! – Yvan Feb 28 '20 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.