Nixos

如何在 NixOS 上啟動 mariadb 服務?

  • November 7, 2017

在我的 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

NixOS 選項services.mysql.enable適用於啟動 MySQL 實現 (mysql-*mariadb)。由哪一個開始決定services.mysql.package

所以在你的/etc/nixos/configuration.nix添加

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

(這樣,您甚至不需要在 . 中明確列出mariadbenvironment.systemPackages

引用自:https://unix.stackexchange.com/questions/403019