Say I have a script on one hosting would it be possible to connect it to a database on another hosting? If so how would I do this?
You can if the other db server allows remote connections, you would simply replace the "localhost" to the address/ port of the db server in the connection string. Given that these types of connections are not encrypted and so you are broadcasting db login details openly across the net most db servers have remote connections turned off
IP is ok but is subject to the host not changing it, most if they allow external connections will give you a url (eg slq.thedomain.com) to prevent this issue as they change the DNS servers and users dont change anything
On the server you are connecting to, assuming that you also have control of it. You should only allow connections from hosts that you know. Your firewall should filter everything to port 3306 except from the hosts you want connecting to it. The last thing you want is for some script to try and brute force your database because it open to the outside.
most of the cpanel based hosts there is option to add IP of the site from which you want to access DB instead of only localhost Regards Alex
all depence. for example, godaddy standard shared hosting doesn't gives you connection from another hosting databases or vice varse. I have godaddy hosting and couldn't connect to another hosting databases. also I don't want to use godaddy for permanent, because very much restrictions.
Instead of the IP I recommend to use the domain name. Example: 88.9.1.2 -> yourdomain.com Use it like this domainort. On a major host, on the same ip could be hosted more than one website. Also, take a look at the host details. For example dreamhost has special mysql server for each domain... like: domain.com is your domain... and mysql.domain.com si the mysql server setting. In this case, yes, you can have external connections. Before you start anything, better ask the hosting support center. They can save your time. Thanks, hyper