Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP MySQL Introduction

PHP MySQL Introduction


Through PHP, you can connect to and manipulate databases.

MySQL is the most popular open-source database system used with PHP.

If you want to learn more about MySQL, you can check out this site'sMySQL Tutorial.


What is MySQL?

Data in MySQL is stored in tables. A table is a collection of related data, containing columns and rows.

Databases are very useful when storing information in categories. A company's database may have the following tables:


PHP + MySQL


Query

A query is an inquiry or request.

Through MySQL, we can query specific information from the database and get back a result set.

Look at the query below (using standard SQL):



mysql> set names utf8;

mysql> SELECT name FROM websites;

+---------------+

| name          |

+---------------+

| Google        |

| 淘宝        |

| Runoob Tutorial  |

| 微博        |

| Facebook      |

| stackoverflow |

+---------------+

6 rows in set (0.00 sec)

The statement **set names utf8;** is used to set the database encoding so that Chinese characters can be displayed normally.

The query above selects all data from the "name" column in the "websites" table.

To learn more about SQL, please visit our SQL tutorial.


Download MySQL Database

If your PHP server does not have a MySQL database, you can download MySQL for free here:http://www.mysql.com.


Facts About the MySQL Database

One great feature of MySQL is that it can be scaled down to support embedded database applications. Perhaps because of this, many people think MySQL can only handle small and medium-sized systems.

In fact, for those websites that support huge amounts of data and traffic (such as Friendster, Yahoo, Google), MySQL is the de facto standard database.

This address provides an overview of companies using MySQL:http://www.mysql.com/customers/.