Reputation: 2449
I am working on a school project in which I have to upload data onto a database hosted on phpMyAdmin.
What's confusing me right now is that I see "localhost" at the top of the page and before I even query the database I see "Run SQL query/queries on server "localhost":"
Does this mean that I'm hosting a server on my computer and accessing the database through that? Because then I query for "SHOW VARIABLES WHERE Variable_name = 'hostname';" and it returns with hostname = webhost330. (It is hosted on webhost330.asu.edu).
I'm extremely confused about what this means. Thanks for any possible help.
I'm very new to databases so forgive me if I'm missing something simple here.
EDIT: To clarify: I'm not at school, I'm at my house. What kind of implications does this have? In other words, what's the difference between this and hosting a database locally?
When I host a database on my computer through the MySQL command line client, I can create database information and it's stored on my computer in files. Does this mean that it's initially stored on localhost and then that data is used to create files on my computer?
And then the equivalent of that for the webhost330 is that the localhost stores the database initially but then uploads it to the host at phpMyAdmin? That is the primary thing I'm confused about.
Upvotes: 2
Views: 6072
Reputation: 9007
To see what "localhost" refers to in terms of MySQL server, you have to look at the URL you are using to connect to the web server.
For example, if the URL is
http://localhost/phpmyadmin
and this instance of phpMyAdmin tells me that the MySQL server is on localhost, this means that the MySQL server is on my local workstation.
If the URL is http://example.com/phpmyadmin, then localhost will mean that the MySQL server is on the same machine (example.com).
Upvotes: 1
Reputation: 46900
This exactly means what you assumed. When connected to localhost
, you are connected to local MySQL server on same machine. Using webhost330....
you are connected to that remote MySQL server instance, if that is not the name of your own machine. Your own server can be webhost30.etcetc
.
Edit
If your website is hosted here: webhost330.asu.edu
then MySQL host either being webhost330.asu.edu
or localhost
both mean the same local MySQL server on your very machine.
Edit based on your update
If you are at home, then localhost
means you are connected to a MySQL server that you have installed on your own computer. and webhost30.etc.etc
means you are connected to the database you have at your school. Database do allow remote connectivity and if you are connected to school from home, that's a remote MySQL connection.
To remove your confusion, you should use only localhost
in your code. localhost
at home will mean the development server which is your home computer, and when you take the same code to webhost30.etc.etc
then localhost
for that server will mean its own MySQL installation. So localhost
will work everywhere as long as you don't want your code to connect to a remote external MySQL database server.
Upvotes: 3
Reputation: 201497
Assuming you're at school, and assuming you're on your school network. Then yes, your machine is probably "webhost330.asu.edu". At the very least webhost330.asu.edu thinks "webhost330.asu.edu" is localhost.
Upvotes: 1