@@ -14,6 +14,11 @@ import ./make-test.nix ({ pkgs, ...} : {
1414 { name = "testdb"; schema = ./testdb.sql; }
1515 { name = "empty_testdb"; }
1616 ];
17+ # note that using pkgs.writeText here is generally not a good idea,
18+ # as it will store the password in world-readable /nix/store ;)
19+ services.mysql.initialScript = pkgs.writeText "mysql-init.sql" ''
20+ CREATE USER 'passworduser'@'localhost' IDENTIFIED BY 'password123';
21+ '';
1722 services.mysql.package = pkgs.mysql;
1823 };
1924
@@ -41,6 +46,8 @@ import ./make-test.nix ({ pkgs, ...} : {
4146 $mysql->waitForUnit("mysql");
4247 $mysql->succeed("echo 'use empty_testdb;' | mysql -u root");
4348 $mysql->succeed("echo 'use testdb; select * from tests;' | mysql -u root -N | grep 4");
49+ # ';' acts as no-op, just check whether login succeeds with the user created from the initialScript
50+ $mysql->succeed("echo ';' | mysql -u passworduser --password=password123");
4451
4552 $mariadb->waitForUnit("mysql");
4653 $mariadb->succeed("echo 'use testdb; create table tests (test_id INT, PRIMARY KEY (test_id));' | sudo -u testuser mysql -u testuser");