Cannot connect to database by remote server - php

i have this problem:
I've created a Cms on my server hosted in Aruba (i call this My-server), i need to connect to a remote server (i call this external-server) to update its Database (Mysql) and ftp uploads via php.
I opened ports and connection in the external-server but it seems that Aruba blocks connection to external servers, even if tunnelling by port 80.
When i use my cms from virtual server (APache) on my laptop all works but when i moved to the server i got problems.
Any advice to solve the problem?
I cannot move my cms to external-server for politicy reason.

In your MySQL config add this
skip-external-locking
and in the config also remove this line below as if this is in place then no outsider can login.
bind-address = 127.0.0.1
restart the MYSQL after this.

You can asked Aruba to provide you access to port 80, 3306 etc. Just ask them I think they will remove it through their firewalls or iptables.

Related

How to connect to remote DB server with IP address and mysqli_connect [duplicate]

I am trying to connect mysql database using php. But it is running fine on local machine but not when hosted online and error appeared as
mysqli_connect(): (HY000/2002): Connection timed out
<?php
$link = mysqli_connect('sql6.freesqldatabase.com','user_name','password','database_name');
if(mysqli_connect_error())
die("couldn't connect to database");
?>
Your MySQL server is probably not configured to accept requests from the host you're trying to access it from.
Check the configuration for the server.
Since you say the local machine can access it check where you permitted this and do the same for the ip of the online host.
In my case, AWS firewall was blocking my web server.
Adding the web servers IP address to the firewall exceptions fixed
this for me.
There might firewall in the host which is blocking the request to MySQL server. In my case adding the firewall rule helped me out.
Ubuntu
To allow one device to access the MySQL server,
sudo ufw allow from remote_IP_address to any port 3306
To allow any device to connect to MySQL server,
sudo ufw allow 3306
It worked!
If your website and MySQL database are hosted on separate servers, make sure that you've mentioned correct MySQL hostname (resolvable) in connection string.
In case you've specified the correct username, most probably your MySQL server isn't allowing remote MySQL connections from web server where you site resides.
Contact your web hosting provider for the exact MySQL hostname and to allow your web server IP address for remote MySQL connections.
I think you have to white list your hosting server's ip address to your DB server.
So your DB server will accept requests from your hosting server.
Specify the port (3306?) to the connection string as well.

Can't connect to remote server on specific port

I need to make a TCP/IP socket server in PHP.
So I downloaded an example from php.net and tried it on my own machine (changed default script socket ip to 127.0.0.1). I opened it from web-browser (because I use XAMMP system, so I can't do a background working shell script), connected to 127.0.0.1:8175 by Telnet and it worked fine!
But now I have a problem:
I uploaded that script to remote server, opened port 8175 on the router and could not connect to the remote port from my computer. But I still can connect to the web and ssh ports on that server.
Any ideas?
If I asked that question in a wrong place, just say it. And... Sorry for my bad English.
If you set socket default IP to 127.0.0.1 you will be able to connect only from the machine running the script. So you need to change it something like your server's IP or 0.0.0.0 to accept all connections but take care of security measures.

Connect to SQL server from localhost

I have a newly set up LAMP system for testing a website I am developing. School has supplied a database that uses a phpmyadmin webinterface. If I host the website on the domain I have been assigned by school, everything works fine, but if I host the same files locally it get the following error:
SQLSTATE[HY000] [2002] Connection timed out
Having read up as much as I could, I suppose some setting restricts my access to an external database when hosting locally, but I am lost as to how to fix this.
I know of the my.cnf file but the skip-networking, and bind-address options were already commented out. Also, I checked that both httpd and mysqld are running.
Odds are very good that the school's database doesn't allow connections from remote IP addresses. Has your instructor specifically told you that you should be able to connect?
To fix it, you'd have to have the system administrator open it up for you.
When you say you edited my.cnf, on what machine did you make those changes? Your local LAMP system or on the school's database server (or convince them to give you VPN access).

Cannot connect to mysql database on remote host

I am not sure if the terms I am using are correct so ask for clarification if you need :).
Anyways, I am hosting through HostEasySolutions (Server A). It comes with a MySql database, using PHPMyAdmin as the frontend. On Server A, I added some PHP files to access the database, and it works fine.
If I copy the php files to my other server, through DreamHost (Server B), I cannot connect to the database. I get the error: Can't connect to MySQL server on 'combinedsystems.ca' (110)
In the cPanel on Server A, I added the IP for Server B into the Remote Database Access Hosts, I also just added the wildcard '%', just to see if I could get it working...but still it can't find the server.
I am not sure what is going on, as far as I can see there is no firewall.
The only thing that stands out to me, is that if I go to PHPmyAdmin for Server A, it says Server: Localhost via UNIX socket, where as for Server B's PHPMyAdmin, it says: Server: mysql.pdem.info via TCP/IP
Most (all?) hosting companies have port 3306 closed on the firewall.
What you need to do:
adding remote database access in the database
edit my.cnf to listen on all interfaces. Default mysql listens only to localhost
most of the time you are out of luck! Even if there is no firewall (would be very unsecure) you have no access to my.cnf

apache/php/mysqli connection to remote db fails but IIS and MySQL workbench connects

I am developing locally and connecting to a remote mysql server. I had been using IIS on my local machine (WinXP) but am now using Apache instead. Most of my PHP site is working correctly after the move to Apache.
But - when mysqli tries to connect to the remote db I get:
(HY000/2003): Can't connect to MySQL server on '...:**' (10060)
I know that the server is accepting connections from my IP because I am able to connect to the same server from my local machine using MySQL Workbench.
I also know that the db connection details I'm using with mysqli are correct because I was using the same details when running on IIS without problem, the only change that happened is that I moved from IIS to Apache.
This problem still exists when my local firewall is disabled.
I have very little experience with Apache, is there perhaps a config setting I've missed that prevents me from connecting out to a remote db, or something that is mangling/hiding reporting of my correct IP?
Thanks for any help, I'm clutching at straws here...
Error 10060 happens when the remote MySQL server does not respond.
It could be that connections to port 3306 on the remote machine are being blocked. It could be that the system hosting PHP/Apache has a software firewall that is blocking the outgoing connection, or that PHP/Apache is not permitted to open network connections by that firewall.

Categories