Welcome to WebmasterWorld Guest from 54.167.76.176

Forum Moderators: open

Message Too Old, No Replies

Do scripts connect to MySQL directly on the same machine,

or over the Internet?

     

MichaelBluejay

12:17 pm on Jun 24, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've used MySQL for years but never really gave any thought to how exactly my Perl scripts establish their connection to the MySQL server. Do my scripts connect to the MySQL server locally on the same machine, or do the scripts find the MySQL server over the Internet? I'm assuming the former, for simplicity and performance, but I think there's a small chance it's the latter so that remote clients could also have the ability to access the server, and because my MySQL server hostnames are in the form of "mysql.example.com", which suggests accessing via the Internet.

I suppose these aren't mutually exclusive -- my scripts could connect directly when they could, and remote clients could connect over the Internet.

One reason I'm wondering is that I've just learned about SQlite, which runs entirely via an include or module directly inside a script. (It doesn't require a database server.) If my MySQL scripts are being served over the Internet, then SQLite would have an advantage for web apps, since the database results would be served locally rather than having to wait for the Internet.

whoisgregg

4:12 pm on Jun 24, 2010 (gmt 0)

WebmasterWorld Senior Member whoisgregg is a WebmasterWorld Top Contributor of All Time 10+ Year Member



MySQL can connect locally (typically by using a server of "localhost") or remotely. I have a web app now that in some cases connects to three different MySQL instances: one local and two separate remote servers.

If your database is local but you are configured to use a subdomain of your own domain then you probably want to change that to be localhost to eliminate any additional time your server may spend looking for itself on the internet. ;)

rocknbil

4:17 pm on Jun 24, 2010 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Additionally, if you eliminate the database server in making your connection, it will default to localhost.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month