在我的 NixOS 17.09 系统上,我已经通过在我的和中mariadb
列出包来安装了。/etc/nixos/configuration.nix
nixos-rebuild
二进制文件现在似乎存在,但是 mariadb 数据库服务似乎没有运行。我怎样才能开始呢?
我试过
$ 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 选项services.mysql.enable
适用于启动 MySQL 实现(mysql-*
或mariadb
)。启动哪一个取决于services.mysql.package
。
因此在您的/etc/nixos/configuration.nix
添加中
services.mysql.package = pkgs.mariadb;
services.mysql.enable = true;
(有了它,您甚至不需要明确列出mariadb
。environment.systemPackages
)