Perl + POO and Mysql error

后端 未结 1 1725
粉色の甜心
粉色の甜心 2021-01-29 02:13

I just learned poo and i got to play with perl, achieved this but I do not get the expected output, problem with mysql? Or bad code?. other thing, the same query runs on console

1条回答
  •  春和景丽
    2021-01-29 02:18

    The OO itself is correct.

    The error message comes from MySQL, denying access for the user 'delkav', but I the user you want to connect with is 'root'.

    Anyway, seems your DBI->connect() line is wrong. To follow the DBD::mysql docs, you must change your line:

    my $connect = DBI->connect("DBI:mysql:$database:$host", $user, $pwd) or die $DBI::errstr;
    

    to

    my $connect = DBI->connect("DBI:mysql:database=$database;host=$hostname;", $user, $pwd) or die $DBI::errstr;
    

    0 讨论(0)
提交回复
热议问题