···240 # Set up the replication master
241242 ( echo "use mysql;"
00243 echo "GRANT REPLICATION SLAVE ON *.* TO '${cfg.replication.masterUser}'@'${cfg.replication.slaveHost}';"
244- echo "update user set Password=password('${cfg.replication.masterPassword}') where User='${cfg.replication.masterUser}';"
245 ) | ${mysql}/bin/mysql -u root -N
246 ''}
247
···240 # Set up the replication master
241242 ( echo "use mysql;"
243+ echo "CREATE USER '${cfg.replication.masterUser}'@'${cfg.replication.slaveHost}' IDENTIFIED WITH mysql_native_password;"
244+ echo "SET PASSWORD FOR '${cfg.replication.masterUser}'@'${cfg.replication.slaveHost}' = PASSWORD('${cfg.replication.masterPassword}');"
245 echo "GRANT REPLICATION SLAVE ON *.* TO '${cfg.replication.masterUser}'@'${cfg.replication.slaveHost}';"
0246 ) | ${mysql}/bin/mysql -u root -N
247 ''}
248
+7-8
nixos/tests/mysql-replication.nix
···19 services.mysql.enable = true;
20 services.mysql.package = pkgs.mysql;
21 services.mysql.replication.role = "master";
00022 services.mysql.initialDatabases = [ { name = "testdb"; schema = ./testdb.sql; } ];
23- services.mysql.initialScript = pkgs.writeText "initmysql"
24- ''
25- create user '${replicateUser}'@'%' identified by '${replicatePassword}';
26- grant replication slave on *.* to '${replicateUser}'@'%';
27- '';
28 networking.firewall.allowedTCPPorts = [ 3306 ];
29 };
30···56 };
5758 testScript = ''
59- startAll;
60-61 $master->waitForUnit("mysql");
62- $master->waitForUnit("mysql");
0063 $slave2->waitForUnit("mysql");
64 $slave2->sleep(100); # Hopefully this is long enough!!
65 $slave2->succeed("echo 'use testdb; select * from tests' | mysql -u root -N | grep 4");