: Remote database connections in mysql and php is it possible? I need to know whether remote database connections are possible in every server? does every host provides the option for remote DB
I need to know whether remote database connections are possible in every server? does every host provides the option for remote DB connection? and further this connection will be the second connection of the system. So there will be multiple database connections. How can I check if a host has enabled remote database connections?
More posts by @Sherry384
2 Comments
Sorted by latest first Latest Oldest Best
Yes, it's possible, both mysql (mysql_connect) and mysqli allow you to specify a host for the connection. However, I suspect you can only check by trying: some hosting services might simply block outgoing connections using a firewall, which may be outside the web host machine and undetectable until you attempt to establish the connection.
If you're connecting to a server outside the same network as the server, it's worth considering turning on SSL.
This is not ideal mysql, since there is nothing to set the SSL options explicitly for your application. At best you can use mysql_options(&mysql->conn,MYSQL_READ_DEFAULT_GROUP, "client");, which will load the configuration from the [client] section of the global MySQL configuration file (on the web server). This can cause problems on a shared host.
If you're using mysqli instead, you should be able to use mysqli::ssl_set.
Most shared hosting accounts require you to give your self access to the mysql server. Usually you enter your IP address or a range to grant remote mysql access. Most other servers if you have root access you configure it yourself. You'll have to ask the hosting companies if remote mysql is allowed or if you have to grant your IP or another servers IP access which is connecting to the db
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.