I've searched so much and still found no answer to what exactly a connection is. I'm a beginner and don't know how connecting to databases/servers works, so I can't move forward yet.

What does the connection connect to and from?

What do I put in the "hostname" and "port" if I'm making a schema for my website at "localhost/magento" in my browser?


  • Most likely localhost and 3306 if MySQL is installed on the same PC. What does the sql-server tag have anything to do with this?
    – topshot
    Jul 1 '19 at 17:15

Are you familiar with "server versus client"? Your program (Workbench, PHP, magento, etc) is the "client". MySQL's program (mysqld) is the server.

If both are on the same computer, the connection can be made via a "socket" and you use "localhost", but no "port".

If they are on separate computers, the client needs to specify where the server is (via hostname or IP address) and port number (or use the default of 3306).

Database products other than MySQL have similar connection protocols.


The typical beginner installs WAMP or LAMP. They contain Apache, MySQL/Workbench/phpmyadmin, and PHP/Perl/Python on Windows or Linux. Everything you need for building and publishing, say, web pages. In that context, everything is on the same computer. Under the hood, there are a lot of moving parts.

As far as connecting, you simply follow the "socket" or "localhost" path.

Meanwhile, the "big guys" have thousands of servers -- some with MySQL, some with web servers (Apache+PHP or whatever), some with "clients" (with WordPress or whatever) and they talk over the network (hostname+port). But you are not a "big guy" yet, so don't worry about this detail.

  • Oh, I have not heard that. So what exactly is MySQL's program? I guess my main problem is I don't know where I have to specify my website URL that I'm making the schema for. Do I even have to do that, or is making connections/schemas only about where the database is, not what website it's for? I just want to make something for my "localhost/website" URL.
    – user184434
    Jul 1 '19 at 18:14
  • @user184434 - I added more.
    – Rick James
    Jul 1 '19 at 18:56
  • so should I put "localhost/magento" into the "hostname" field, and 0 into the port field, if that's where my website is?
    – user184434
    Jul 1 '19 at 19:52
  • @user184434 - Just "localhost" in the "hostname" field; ignore the port field. I am assuming you are talking about how to get to MySQL from your client??
    – Rick James
    Jul 1 '19 at 20:34
  • I just thought that my website URL somehow needed to be specified when creating a new connection/schema.
    – user184434
    Jul 1 '19 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.