如何为Test :: DBIX :: Class设置mysql沙箱?

时间:2017-02-02 12:12:22

标签: mysql perl dbix-class

我试图用MySQL::Sandbox设置Test :: DBIX :: Class。但看起来我的设置不正确,因为警告消息:

Test-DBIx-Class-0.52$ mysql_install_db=$HOME/opt/sandbox/mysql/5.5.54/bin/mysqld BASE_DIR=/tmp/sandboxes/msb_5_5_54 prove -l t/08-test-mysqld.t 
t/08-test-mysqld.t .. mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13 - Permission denied)
t/08-test-mysqld.t .. ok   
All tests successful.
Files=1, Tests=7, 28 wallclock secs ( 0.02 usr  0.00 sys +  1.05 cusr  0.57 csys =  1.64 CPU)
Result: PASS

/var/lib/mysql/不是我的mysql沙箱设置的一部分。警告信息的原因是什么?

我使用08-test-mysqld.t进行测试。

我的mysql sanbox设置:

$all_info = {
              '5554' => {
                          'opt' => {
                                     'datadir' => $HOME.'/sandboxes/msb_5_5_54/data',
                                     'log_error' => 'msandbox.err',
                                     'socket' => '/tmp/mysql_sandbox5554.sock',
                                     'prompt' => '\'mysql [\\h] {\\u} (\\d) > \'',
                                     'bind_address' => '127.0.0.1',
                                     'tmpdir' => $HOME.'/sandboxes/msb_5_5_54/tmp',
                                     'user' => 'me',
                                     'lower_case_table_names' => '0',
                                     'basedir' => $HOME.'/opt/sandbox/mysql/5.5.54',
                                     'port' => '5554',
                                     'pid_file' => $HOME.'/sandboxes/msb_5_5_54/data/mysql_sandbox5554.pid',
                                     'password' => 'msandbox'
                                   },
                          'conf' => undef
                        }
            };

1 个答案:

答案 0 :(得分:0)

警告消息在Test::mysqld::_use_mysqld_initialize中生成,可以忽略。设置MYSQL_INSTALL_DB后,它可以正常工作:

这是我目前的测试设置:

export SB_DIR=$HOME/opt/sandbox/mysql/5.5.54
Test-DBIx-Class-0.52$ MYSQLD=$SB_DIR/bin/mysqld \
MYSQL_INSTALL_DB=$SB_DIR/scripts/mysql_install_db \
KEEP_DB=1 \
prove -lv t/08-test-mysqld.t

KEEP_DB有助于诊断目的。