sverma has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I've a perl script which fails sometimes with the Unknown MySQL server host 'hostname' (1).

The issue is intermittent and happens once in a month or so. However I am not able to find the exact reason.

The connection is achieved using the below line:

my $mysql_keys_dsn = "DBI:mysql:mysql_read_default_group=keys; mysql_read_default_file=/usr/local/import/perlDB.cfg";

perlDB.cfg contains the below entry

[keys] user='xxxxx' password='xxxxx' host='hostname'

Below is the exact error incurred: FAILED: DBI connect('mysql_read_default_group=keys;mysql_read_default_file=/usr/local/import/perlDB.cfg;database=hosted','',...) failed: Unknown MySQL server host 'hostname' (1) at ./key_data.ora.pl line 358 Can't call method "prepare" on an undefined value at ./key_data.ora.pl line 190.

Replies are listed 'Best First'.
Re: Failed DBI:failed: Unknown MySQL server host 'hostname' (1)
by Anonymous Monk on Sep 29, 2015 at 06:55 UTC

    The issue is intermittent and happens once in a month or so. However I am not able to find the exact reason.

    Its the nature of networks/internet, sometimes you're able to resolve a hostnames, other times you're not able to resolve them -- thats networking