1

I am trying to log-in remotely to MySQL server which is running on my Disk station, over the network. I confirm that MySQL is running on the disk station, I have php running on the disk station and I can check via remote connection to disk station phpMyAdmin and MySQL queries are answered.

On my laptop, I have created the following PHP script and when I try to run this script on my laptop, I get the following error message

<?php // login.php

$hn = 'bio12' ; //disk station name
$db = 'mysql' ; //database I want to connect to
$un = 'mysqluser' ; // user name
$pwd = 'abctest123' ; // password for the user

$conn  = mysql_connect($hn, $un, $pwd);

if(! $conn){
  die('Could not connect') ;
}

echo 'Successfully Connected';

?>

Error message: Warning: mysql_connect(): No connection could be made because the target machine actively refused it. in C:\xampp\htdocs\login.php on line 15 Could not connect

I have tried using the IP address instead of 'bio12' but without success.

Interesting enough, when I use the same code and try to connect to local mysql (I am running XAMP on my laptop) and using the 'localhost' instead of 'bio12' it works just fine.

What am I doing wrong?

Francisco
  • 10,918
  • 6
  • 34
  • 45
Ishti
  • 11
  • 2
  • 1
    MySQL as default does not allow connection out of localhost. This thread might help you https://stackoverflow.com/questions/14779104/how-to-allow-remote-connection-to-mysql – Victor Hugo Montes Aug 17 '17 at 20:05
  • 1
    Thank you for the link. It was helpful. One point to mention, my MySQL is running on a disk station and interesting enough I could not find a my.cnf file. It looks like, I would have to create one. – Ishti Aug 18 '17 at 14:25

1 Answers1

0

You need to allow remote connections. Find line in your mysql config (my.cnf file)

bind-address = 127.0.0.1

and comment it with "#" at the beginning, please also see this thread: How to allow remote connection to mysql

mitch
  • 2,235
  • 3
  • 27
  • 46