简体   繁体   English

帮助将perl dbi与mysql一起使用以查询远程数据库

[英]help using perl dbi with mysql to query a remote database

I need help figuring out this configuration and the use of mysql perl DBI. 我需要帮助弄清楚此配置以及mysql perl DBI的使用。

My local connection works fine, but once I try to query a remote host db I am getting errors. 我的本地连接工作正常,但是一旦尝试查询远程主机数据库,就会出错。 I know my setup to the remote db works as I can do the following from a shell: 我知道我对远程数据库的设置可以正常工作,因为我可以从外壳中执行以下操作:

WORKS: 作品:

$ mysql -u foo-man -pmypa55w0rd --database abc -h abc123.name.locale --port 3306 -ss -e "select UUID()"  

From using the perl DBI, localhost works too: 通过使用perl DBI, localhost也可以工作:

my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost:port=3306;user=root");

But using perl DBI, querying a remote database, NO luck. 但是使用perl DBI来查询远程数据库,就没有运气了。

DOESN'T WORK: 不工作:

my $dbh = DBI->connect("DBI:mysql:database=abc;host=abc123.name.locale;port=3306;user=foo-man,password=mypa55w0rd"); 

nor using the IP for example: 也不使用IP例如:

my $dbh = DBI->connect("DBI:mysql:database=abc;host=123.567.89.10;port=3306;user=foo-man,password=mypa55w0rd");

I would use 我会用

my $dbh = DBI->connect("DBI:mysql:database=abc;host=abc123.name.locale;port=3306",
                       'foo-man', 'mypa55w0rd');

But it would probably also work if you changed the comma after the username to a semicolon. 但是,如果您在用户名后将逗号更改为分号,也可能会起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM