I have some php
scripts that use mysqli()
to connect to MySQL
which is located on the same server. I currently have the connection stored outside of my sites root
and I am using include()
to make the connection.
For remoteMySQL
servers it is recommended to use an ssh
connection. For my environment, should I take any other measures to secure my connection?
Also is it more of a concern that mysql
is on the same server?
Lastly I am guessing I would want to prevent any errors resulting from the connection being displayed as they would give connection information.
EDIT
Im also curious as to if/when I would want to close()
these connections. I am guessing I would want to close them but only after I am done accessing the database on a particular page.
EDIT 2
Still looking for the above information as of 12.11.2019
ssh
would be considered a minimum requirement if you do need to allow remote connections. You don't need to explicitly close connections. That is done when the PHP script is finished. Usetry/catch
for the connection to make sure no connection information gets "leaked". Also set your logging to always go to the PHP error log instead of having it displayed.