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;
Windows Perl Scripting Forums » General
DBI permissions problem
(8 posts)-
Posted 4 years ago #
-
How are you running the script? Is it on a command line or from a service or web page?Posted 4 years ago #
-
Running it from a command line now for testingPosted 4 years ago #
-
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 4 years ago #
-
how do i check thatPosted 4 years ago #
-
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 4 years ago # -
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 4 years ago # -
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 3 months ago #
Reply
You must log in to post.