February 21st, 2013, 12:22 AM
-
Connecting Database on Unix server through Windows Perl script
I am just wondering if I can connect the database that is on Linux server through Windows Perl script.
Is it possible ?? If the answer is yes then any idea how we can connect Unix database with Windows Perl programming.
Thanks in advance.
February 21st, 2013, 01:28 AM
-
Yes, in principle you can, using the DBI (database interface) module. Of course, it will depend on which database type it is and how you can access to your linux server from your windows box, but it is usually possible and even quite simple.
February 21st, 2013, 02:15 AM
-
Okey, so we can connect like this,
$dsn = "DBI:driver:database=$database;host=$hostname;port=$port";
Let me try this, Thanks a lot :-)
February 21st, 2013, 08:58 AM
-
Assuming a MySQL db, it would need to be configured to permit access from remote hosts ...
--Ax
without exception, there is no rule ...
Handmade Irish Jewellery
Targeted Advertising Cookie Optout (TACO) extension for Firefox
The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones


09 F9 11 02
9D 74 E3 5B
D8 41 56 C5
63 56 88 C0
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. -- Jamie Zawinski
Deta
vil - the devil is in the detail, allegedly, and I use the term advisedly, allegedly ... oh, no, wait I did ...
BIT COINS ANYONE
February 22nd, 2013, 01:31 AM
-
Thank you very much for your inputs.
@Axweildr, yes I am using MySql DB (that is on unix server). Any idea how to give the permit access for the remote host ??
code snippet :-
use DBI;
my $database ="test";
my $hostname = "IP ADDRESS";
my $port = "3306";
$dsn = "DBI:mysql:database=$database;host=$hostname;p ort=$port";
#$dbh = DBI->connect($dsn, $user, $password);
$dbh = DBI->connect($dsn, 'mysql', '', {RaiseError => 1});
$drh = DBI->install_driver("mysql");
$sth = $dbh->prepare("SELECT * FROM employee");
$sth->execute;
Error :-
DBI connect('database=test;host=IP ADDRESS;port=3306','mysql',...) failed: Can't connect to MySQL server on 'IPADDRESS' (10060) at ....
Looks like I need to give remote permission to MySql ....
Thanks in advance :-)
February 22nd, 2013, 03:27 AM
-
Granted the permission to the mysql user for windows box ip id....
mysql> GRANT ALL PRIVILEGES ON test.* TO mysql@'WINDOWS_IP_ADDRESS' IDENTIFIED BY '';
Query OK, 0 rows affected (0.00 sec)
Can you please let me know if the above way is correct for permission granting...
February 22nd, 2013, 08:15 AM
-
That is the correct way to assign/grant the db permissions, but there is one additional step to enable those permissions.
mysql> flush privileges;
Query OK, 0 rows affected (0.11 sec)
February 28th, 2013, 11:48 PM
-
Thanks FishMonger :-)
My Perl code seems to be correct but I think the MySql port 3306 is not enable for listening on my Windows box because of firewall security.
Thanks to you all once again.