在我的 NixOS 17.09 系统上,我通过在 my和ingmariadb
中列出软件包来安装。/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
)