PHP MySQL Introduction

What is MySQL

MySQL stands as one of the most widely used relational database systems on the internet today. It is freely available and easy to install. If you've installed Wampserver, MySQL is already included on your machine. MySQL offers several benefits:

  • MySQL is user-friendly yet powerful, fast, secure, and scalable.
  • It operates on a variety of operating systems, including UNIX/Linux, Microsoft Windows, Apple macOS, and others.
  • MySQL supports standard SQL (Structured Query Language).
  • It serves as an ideal database solution for both small and large applications.
  • MySQL is developed and distributed by Oracle Corporation.
  • It includes robust data security features to safeguard sensitive information from unauthorized access.

MySQL databases store data in tables, similar to other relational databases. A table is a collection of related data organized into rows and columns.

Each row in a table represents a data record connected to others, such as details about a specific individual. Each column represents a distinct field, like id, first_name, last_name, email, etc. A typical MySQL table structure for storing general information about people might look like this:

+----+------------+-----------+----------------------+
| id | first_name | last_name | email                |
+----+------------+-----------+----------------------+
|  1 | Peter      | Parker    | peterparker@mail.com |
|  2 | John       | Rambo     | johnrambo@mail.com   |
|  3 | Clark      | Kent      | clarkkent@mail.com   |
|  4 | John       | Carter    | johncarter@mail.com  |
|  5 | Harry      | Potter    | harrypotter@mail.com |
+----+------------+-----------+----------------------+

Tip: Major websites like Facebook, Twitter, and Wikipedia rely on MySQL for their storage needs. This demonstrates the extensive capabilities of MySQL.


Using SQL to Interact with MySQL Databases

SQL, which stands for Structured Query Language, is a straightforward and standardized language used for managing relational databases such as MySQL. It allows you to perform various tasks related to databases, including creating databases and tables, inserting data into tables, querying databases for specific records, and updating or deleting data.

Consider the following standard SQL query that retrieves the email address of a person whose first name is 'Peter' from the persons table:

SELECT email FROM persons WHERE first_name="Peter"

Executing the SQL query above would yield the following result:

peterparker@mail.com

To delve deeper into SQL, you can explore our SQL tutorial section.