Openshift Perl script can't connect to MYSQL -
embarrassed have ask of openshift guys, perl won't connect mysql, though php fine.
following code works fine on client (i added openshift env variables on local machine) fails on openshift app:
my $db_name = 'campaignmotor'; $db_host = $env{'openshift_mysql_db_host'}; $db_port = $env{'openshift_mysql_db_port'}; $db_pw = $env{'openshift_mysql_db_password'}; $db_user = $env{'openshift_mysql_db_username'}; sub db_connect { $dsn = "dbi:mysql:database=$db_name;host=$db_host;port=$db_port"; $dbh = dbi->connect($dsn, $db_user, $db_pw); return $dbh; }
i unending messages like: error 2002 (hy000): can't connect local mysql server through socket '/var/lib/mysql/mysql.sock' (2)
following php config on web app works fine:
$db['default']['hostname'] = getenv('openshift_mysql_db_host') . ':' . getenv('openshift_mysql_db_port'); $db['default']['username'] = getenv('openshift_mysql_db_username'); $db['default']['password'] = getenv('openshift_mysql_db_password'); $db['default']['database'] = 'campaignmotor';
mysql, mysqldump etc. work on command line.
this haproxy php application
odd thing have no openshift_mysql_db_socket variable. of helper threads on topic reference that.
thanks in advance!
corey - thanks!
in shell command above, specify -h option host, or else yes, try use socket.
and i'll add need specify port well, since in haproxy mode mysql runs on non-standard port number. added both -h host , -p port, , works!
i might have stumbled on except command worked expected when run direct on shell, without port number , host specified. weird!
thanks again!
Comments
Post a Comment