Introduction to PHP & MySQL
With PHP, you can connect to and manipulate databases.
MySQL is the most popular open-source database system used with PHP.
To learn more about MySQL, you can check out our MySQL Tutorial.
What is MySQL?
- MySQL is a database system used on the web.
- MySQL is a database system that runs on a server.
- MySQL is ideal for both small and large applications.
- MySQL is very fast, reliable, and easy to use.
- MySQL uses standard SQL.
- MySQL compiles on a number of platforms.
- MySQL is free to download and use.
- MySQL is developed, distributed, and supported by Oracle Corporation.
- MySQL is named after the daughter of the company's co-founder, Monty Widenius: My.
Data in MySQL is stored in tables. A table is a collection of related data, consisting of columns and rows.
Databases are very useful for organizing information in categories. A company's database might include the following tables:
- Employees
- Products
- Customers
- Orders
PHP + MySQL
- PHP combined with MySQL is cross-platform. (You can develop on Windows and deploy on Unix platforms.)
Queries
A query is a question or request for information.
With MySQL, we can query the database for specific information and get a record set returned.
Here is a query example (using standard SQL):
mysql> set names utf8;
mysql> SELECT name FROM websites;
+---------------+
| name |
+---------------+
| Google |
| Taobao |
| tutorialpro.org|
| Weibo |
| Facebook |
| stackoverflow |
+---------------+
6 rows in set (0.00 sec)
The statement set names utf8; is used to set the database encoding, allowing Chinese characters to display correctly.
The above query selects all data from the "name" column in the "websites" table.
To learn more about SQL, visit our SQL Tutorial.
Downloading MySQL Database
If your PHP server does not have the MySQL database, you can download it for free here: http://www.mysql.com.
Facts About MySQL Database
One great feature of MySQL is that it can be scaled down to support embedded database applications. Perhaps for this reason, many people believe that MySQL can only handle small to medium-sized systems.
In fact, for websites that support massive amounts of data and traffic (like Friendster, Yahoo, and Google), MySQL is the de facto standard database.
This link provides an overview of companies using MySQL: http://www.mysql.com/customers/.