LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Perl script updating one database but not another. (https://www.linuxquestions.org/questions/programming-9/perl-script-updating-one-database-but-not-another-4175473245/)

dalonzoVC 08-13-2013 10:30 AM

Perl script updating one database but not another.
 
I have a script that works fine on one mysql database and fails to update in another.

Code:

use strict;
use warnings;
use DBI;

sub dbOpen {
    my $dsn;
    my $dbh;

    $dsn = "DBI:mysql:database=DATABASEB;host=localhost;port=3306";
    $dbh = DBI->connect( $dsn, "USERNAME", "PASSWORD" ) ||
    print STDERR "FATAL: Could not connect to database.\n$DBI::errstr\n";
    $dbh->{ AutoCommit } = 0;
    return($dbh);
} # END sub dbOpen

my $Data;
$Data = &dbOpen();

my ($sql,$rs,$sql_update_result);

$sql = "update TABLENAME set option_value='http://URL' where option_value='http://STAGINGURL';";
$rs = $Data->prepare( $sql );
$rs->execute() || &die_clean("Couldn't execute\n$sql\n".$Data->errstr."\n" );
$Data->disconnect();

Since this works fine on DatabaseA and not on DatabaseB I presume it is a permission issue, but the username I am using has ALL permissions on *.* so I am a bit lost.

Thoughts?

Kustom42 08-14-2013 07:11 PM

What do your mysql logs say? They should report any errors in there so if the query is actually get to mysqld it should have the fatal error in there if there is in fact one.

chrism01 08-14-2013 11:08 PM

So what does
Code:

$Data->errstr
say ?

zhjim 08-15-2013 04:01 AM

Did you try it outside of your script? Also the username might have all the permission does it also have a allowed host set inside of mysql.user(s)?


All times are GMT -5. The time now is 08:36 PM.