1

On my NixOS 17.09 system, I've installed mariadb, by listing the package in my /etc/nixos/configuration.nix and nixos-rebuilding.

The binaries now seem to be present, but the mariadb database service doesn't seem to be running. How can I start it?

I tried

$ sudo systemctl start mariadb
Failed to start mariadb.service: Unit mariadb.service not found.
$ sudo systemctl start mysql
Failed to start mysql.service: Unit mysql.service not found.
$ sudo mysqld start
2017-11-06 11:39:35 140359451949120 [Note] mysqld (mysqld 10.1.28-MariaDB) starting as process 2823 ...
2017-11-06 11:39:35 140359451949120 [Warning] Can't create test file /var/lib/mysql/nixos.lower-test
mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 2 "No such file or directory")
2017-11-06 11:39:35 140359451949120 [ERROR] Aborting
1

NixOS option services.mysql.enable works for starting either MySQL implementation (mysql-* or mariadb). Which one gets started is determined by services.mysql.package.

So in your /etc/nixos/configuration.nix add

  services.mysql.package = pkgs.mariadb;
  services.mysql.enable = true;

(With that, you don't even need to explicitly list mariadb in environment.systemPackages.)

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.