Windows Perl Scripting Forums » General

DBI permissions problem

(8 posts)

  1. akearins
    Member

    getting the following error when I run the code below:

    DBI connect('db_name:server_name','test'.........) failed:Access denied for user 'test'@server_name(using passowrd NO)at.....(path to database).

    When i run MySql command line client I enetr the password and no problem looking at databases, tables etc. or writing queries.

    But when i run teh script bang,......

    Is there any way i can check to see if I have permisiosn to use database

    Any help greatful


    use strict;
    use DBI;


    my($query);
    my $server ='server_name';
    my $db ='db_name';
    my $usrnme ='test';

    my $pwd ='21';

    my $dbh = DBI->connect("dbi:mysql:$db:$server", $usrnme, $pwd)
    or die $DBI::errstr;


    my $query="SELECT * FROM ping_lab";

    my $sth = $dbh->prepare($query);
    $sth->execute();

    while (my $row = $sth->fetchrow_arrayref) {
    print join("\t", @$row),"\n";
    }

    $dbh->disconnect;
    Posted 12 years ago #
  2. Dave
    Perl guy

    How are you running the script? Is it on a command line or from a service or web page?
    Posted 12 years ago #
  3. akearins
    Member

    Running it from a command line now for testing
    Posted 12 years ago #
  4. Dave
    Perl guy

    I tried your code on my system and it worked just fine. Are you sure that the server is listening to the default port (I think it is 3306)? If not then make sure that you specify the port number.
    Posted 12 years ago #
  5. akearins
    Member

    how do i check that
    Posted 12 years ago #
  6. akearins
    Member

    thanks for all your help , found fix for it.Problem connecting with password
    Ran command mysql -u root -p test
    But still one slight problem.

    I have added tp previous code to insert the output from the file directly intoa table in MqSql database.

    But I have a problem with the date format.

    My SQl is using Type dateTime (YYY-MM-DD hh:mm:ss)
    but was using my $date = localtime (Wed Jul 26 10:52:46 2006) in perl script.

    is there a date format I can use in perl to be the same as format I am suing in MySql dbase. Need both to be the same as getting errors when running script.
    Posted 12 years ago #
  7. msperl
    Administrator

    Alot of coders use the integer value of time(). You can then pass that into localtime(). Set up your SQL table to accept the date stamp as an 32 bit integer then in your insert command pass in the result of time(). Since it is an integer it is easy for SQL to index it.
    In a SQL query you can get the date as a string by using the function FROM_UNIXTIME().
    Posted 12 years ago #
  8. Anonymous

    you installed it by hand? i'am wondering if the make test worked for you? if a test fails and i think this is no problem, i usually just use (with cpanp) skiptest 1 and so the tests are not performed and often the module installs fine.

    Posted 8 years ago #

RSS feed for this topic

Reply

You must log in to post.