Connecting to databases
Connecting to a database is by far the easiest thing to do; however, we need to keep a few things in mind. To connect to any database, we need at least four things to be in place:
- We need a host to connect to
- We need a database to connect to that is running on a port
- We need a username
- We need a password
The user needs to have appropriate privileges because we not only want to connect but we would like to perform specific operations, such as query, insert, or remove data, create or delete databases, and manage users and views. Let’s imagine that connecting to a database is like walking up to a door as a specific person with a specific key. Whether the door opens or not depends on the key, but what we can do after we have crossed the threshold will depend on the person (which is defined by their privileges).
In most cases, the database server supports multiple databases, and the databases hold one or more tables: