Working with MySQL

Working with MySQL

There are a number of RDBMS packages available. These programs vary in power, flexibility, and price. However, they all work in essentially the same way. For this book, most examples will use the MySQL database. This program is very frequently paired with PHP for a number of reasons. First, MySQL is a very powerful program in its own right. It handles a large subset of the functionality of the most expensive and powerful database packages. It uses a standard form of the well-known SQL data language. MySQL is released under an open source license, and is available for free. It works on many operating systems, and with many languages. It works very quickly and works well even with large data sets. PHP ships with a number of functions designed to support MySQL databases.

Installing MySQL

If you used PHPTriad to install Apache and PHP, you probably also installed MySQL as well. If you are working on a Web server you do not control, you'll need to check with your server administrator to see if MySQL is installed. If your server supports PHP, it's very likely that it also supports MySQL, as these two programs are frequently installed together.

Using the MySQL Executable

MySQL is actually a number of programs. It has a server component that is always running, as well as a number of utility programs. The MySQL command line console shown in Figure 7.5 is a basic program run from the command line. It isn't a very pretty program, but it provides powerful access to the database engine.

Click To expand
Figure 7.5: The MySQL program connecting to a database.

There are a number of ways to use MySQL, but the basic procedure involves connecting to a MySQL server, choosing a database, and then using the SQL language to control the database by creating tables, viewing data, and so on.

The MySQL.exe console shipped with MySQL is the most basic way to work with the MySQL database. Although it won't win any user interface awards, the program offers low-level access to the database. This interface is important to learn, however, because it is very much like the way your programs will interface with the database system.