title: MySQL server connection not working from perl script using DBI but works from command line and GUI too
body: <p>I am trying to connect to MySQL database on a remote server using the Perl DBI AND DBD::MySQL Modules,but getting the error below</p>
  
  <p>"DBI connect('database=user_rohan;host=hostname;port=3306','rohan',...) failed: Can't connect to MySQL server"</p>
  
  <p>I am logged in on my remote server through command line,since I did not find any option to login to the server in the Perl script.Below is my script:</p>
  
  <pre><code>#!/usr/bin/perl
  use strict;
  use warnings;
  use DBI;
  use DBD::mysql;
  my $host = 'hostname';
  my $user = 'rohan';
  my $dbh   =DBI&gt;connect("dbi:mysql:database=user_rohan;host=$host;port=3306","$user","password", {'RaiseError' =&gt; 1});
  </code></pre>
  
  <p>While,Installing the Perl DBD:MySQL modules,I faced a lot of issues but was able  to install the module successfully and ran my tests as well.
  I find a similar question asked earlier but was not able to solve from reading the answers in its comments.</p>
  
  <p>Thanks,</p>
  
  <p>Rohan</p>