title: local server connection to remote mysql
body: <p>I have found this question here and around internet for few times, but none answered helped me.</p>
  
  <p>So I have a local apache+php server and trying to connect to remote mysql database. But script returns me error and in error log i see:</p>
  
  <pre><code>PHP Warning:  mysql_connect(): Premature end of data (mysqlnd_wireprotocol.c:553) in D:\\_SERVER\\_WWW\\project\\api\\classes\\database.php on line 13
  PHP Warning:  mysql_connect(): OK packet 1 bytes shorter than expected in D:\\_SERVER\\_WWW\\project\\api\\classes\\database.php on line 13
  PHP Warning:  mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file in D:\\_SERVER\\_WWW\\project\\api\\classes\\database.php on line 13
  </code></pre>
  
  <p>The script for connection (just the part connecting to server):</p>
  
  <pre><code>function db_connect(){
      // Connect to the database server
      $connection = mysql_connect("server.com:3306","username","password",true);
      if (!$connection){
          echo "Could not connect to the Database server, please check your settings";
          die;
      }
  ...
  }
  </code></pre>
  
  <p>The trick with setting PASSWORD did not work for me, can someone please help me ?</p>
  
  <p>Thank you</p>