The error : No connection could be made because the target machine actively refused it.
I've looked through many topics that I could find out here but none of them seemed to be useful for my situation.
My setup :
I have two VM's running in their own network 192.168.11.0 . I can ping the other machine from within the other. I have no firewalls on them.
The one, with end IP 129, called SQLTest has Microsoft SQL Server 2012 running with Windows and SQL Authentication. Made a user/login called "root" with SQL auth and gave that user rights to the server and the database and everything else he needs access to. I tested logging on SQL Server Management and that works fine. The SQL Server is running and the SQL Server browser is running too.
The other, with end IP 131, called WEBSERVER has WAMP running, latest with updates. I have a php running that connects or tries to connect to this machine and display data, but I get the error message. That message tells me that it finds that host, but can't get access to it for some or other reason. As I've mentioned earlier, that system has no firewalls on.
Here is my PHP :
$host="192.168.11.129:1433";
$username="root";
$password="abc123";
$con=mysqli_connect($host, $username, $password);
On my SQL Server configuration Manager, I enabled named pipes, and everything else essential. The IP address I have listed there is 127.0.0.1 and the port is 1433. I also tried setting that IP to 192.168.11.29 but that doesn't do anything. I checked with nbtstat -abn
and port 1433 seems ok and is listed.
You have to define database name to connect. As in your code there is no such database selected to connect.You need to grant permission to user for remote access of MySQL using any IP or any specific IP. To grant permission for database to any mysql user to access the db. Go through below URL to grant permission.
Make sure you have the correct drivers (http://www.microsoft.com/en-us/download/details.aspx?id=20098). and then check out this link How to get mssql work with PHP 5.3?. Don't mix up Microsoft SQL Server with MySQL
The solution was that I edited the settings in the SQL Server Configuration Manager :
1.) IP2, should be the IP of the server, in this case 192.168.11.129 2.) In IPAll, the Dynamic port must be blank, in my case it was 43525 or something.
Once I changed this, the connection was able to commence without the error.