1Test::mysqld(3pm)     User Contributed Perl Documentation    Test::mysqld(3pm)
2
3
4

NAME

6       Test::mysqld - mysqld runner for tests
7

SYNOPSIS

9         use DBI;
10         use Test::mysqld;
11         use Test::More;
12
13         my $mysqld = Test::mysqld->new(
14           my_cnf => {
15             'skip-networking' => '', # no TCP socket
16           }
17         ) or plan skip_all => $Test::mysqld::errstr;
18
19         plan tests => XXX;
20
21         my $dbh = DBI->connect(
22           $mysqld->dsn(dbname => 'test'),
23         );
24
25         # start_mysqlds is faster than calling Test::mysqld->new twice
26         my @mysqlds = Test::mysqld->start_mysqlds(
27           2,
28           my_cnf => {
29             'skip-networking' => '', # no TCP socket
30           }
31         ) or plan skip_all => $Test::mysqld::errstr;
32         Test::mysqlds->stop_mysqlds(@mysqlds);
33

DESCRIPTION

35       "Test::mysqld" automatically setups a mysqld instance in a temporary
36       directory, and destroys it when the perl script exits.
37

FUNCTIONS

39   new
40       Create and run a mysqld instance.  The instance is terminated when the
41       returned object is being DESTROYed.  If required programs
42       (mysql_install_db and mysqld) were not found, the function returns
43       undef and sets appropriate message to $Test::mysqld::errstr.
44
45   base_dir
46       Returns directory under which the mysqld instance is being created.
47       The property can be set as a parameter of the "new" function, in which
48       case the directory will not be removed at exit.
49
50   copy_data_from
51       If specified, uses a copy of the specified directory as the data
52       directory of MySQL.  "Mysql" database (which is used to store
53       administrative information) is automatically created if necessary by
54       invoking mysql_install_db.
55
56   my_cnf
57       A hash containing the list of name=value pairs to be written into
58       my.cnf.  The property can be set as a parameter of the "new" function.
59
60   mysql_install_db
61   mysqld
62       Path to "mysql_install_db" script or "mysqld" program bundled to the
63       mysqld distribution.  If not set, the program is automatically search
64       by looking up $PATH and other prefixed directories.
65
66   dsn
67       Builds and returns dsn by using given parameters (if any).  Default
68       username depends on a server version and a socket family.  Default
69       dbname is 'test'.
70
71   pid
72       Returns process id of mysqld (or undef if not running).
73
74   start
75       Starts mysqld.
76
77   stop
78       Stops mysqld.
79
80   setup
81       Setups the mysqld instance.
82
83   read_log
84       Returns the contents of the mysqld log file.
85
86   start_mysqlds
87       Create and run some mysqld instances, and return a list of
88       "Test::mysqld".
89
90   stop_mysqlds
91       Stop some mysqld instances.
92
94       Copyright (C) 2009 Cybozu Labs, Inc.  Written by Kazuho Oku.
95

LICENSE

97       This program is free software; you can redistribute it and/or modify it
98       under the same terms as Perl itself.
99
100       See <http://www.perl.com/perl/misc/Artistic.html>
101
102
103
104perl v5.36.0                      2023-01-20                 Test::mysqld(3pm)
Impressum