Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Do scripts connect to MySQL directly on the same machine,

or over the Internet?

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 12, 2003
votes: 0

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.
4:12 pm on June 24, 2010 (gmt 0)

Senior Member from US 

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

joined:Dec 9, 2003
votes: 0

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. ;)
4:17 pm on June 24, 2010 (gmt 0)

Senior Member

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

joined:Nov 28, 2004
votes: 0

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

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members