Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

cross platform

by s.urolagin (Initiate)
on Dec 18, 2012 at 08:19 UTC ( #1009306=perlquestion: print w/ replies, xml ) Need Help??
s.urolagin has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Can i run mysql in Linux and execute Perl script from Window to access the database in Linux? Is this possible, please let me know

Comment on cross platform
Re: cross platform
by Anonymous Monk on Dec 18, 2012 at 08:38 UTC
    Yes, it is possible
Re: cross platform
by GrandFather (Cardinal) on Dec 18, 2012 at 08:59 UTC

    If you set your MySQL server up correctly the same script will run on either platform without change. I have dozens of scripts that do just that using DBI and DBD::mysql.

    True laziness is hard work
Re: cross platform
by space_monk (Chaplain) on Dec 18, 2012 at 09:35 UTC

    I presume you are talking about running MySQL and Perl on different servers, or maybe on VMs? :-). In any event, your Perl program will be perfectly happy as a DBI database connection doesn't care where the server is or what operating system the database is running on as long as you configure it correctly.

    You can even run MySQL in Windows - I wouldn't normally suggest this but it may be helpful in your case.

    A Monk aims to give answers to those who have none, and to learn from those who know more.
Re: cross platform
by bart (Canon) on Dec 18, 2012 at 11:39 UTC
    MySQL uses internet sockets to access the database. That implies that, not only can you access the MySQL server from a script from a different computer over the network, you can even access it over the internet, if MySQL is set up to allow login access for remote users. So it's both a blessing and a curse.

    See here on how you (or at least someone with database admin access) can allow remote access. 'localhost' means access from the same machine, while '%' means access from anywhere on the internet who can reach the machine (as a firewall might still block it). I think it must be possible to specify a specific host, or even an intranet mask, like '192.168.%', so remote login access is automatically limited even if the firewall allows access; but I've not ever actually tried it, nor have I read anywhere that it is possible. It just looks like a very database-like behaviour to do it like that.

    Update Whoops. At the bottom of the same page that I linked to, it clearly describes that it does indeed work as I suspected. I quote:

    To create a user who has access from all machines in a given domain (for example, mydomain.com), you can use the % wildcard character in the host part of the account name:
    mysql> CREATE USER 'myname'@'%.mydomain.com' IDENTIFIED BY 'mypass';
    To do the same thing by modifying the grant tables directly, do this:
    mysql> INSERT INTO user (Host,User,Password,...) -> VALUES('%.mydomain.com','myname',PASSWORD('mypass'),...); mysql> FLUSH PRIVILEGES;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1009306]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2014-11-28 11:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (196 votes), past polls