Flylib.com

Books Software

 
 
 

1.2. The MySQL Package


1.2. The MySQL Package

The MySQL package comes with several programs. Foremost is the MySQL server, represented by the mysqld daemon. The daemon listens for requests on a particular port (3306 by default) by which clients submit queries. The standard MySQL client program is simply called mysql . With this text-based interface, a user can log in and execute SQL queries. This client can also accept queries from text files containing queries, and thereby execute them on behalf of the user or other software. However, most MySQL use is done by programs using a variety of languages. The interfaces for Perl, PHP, and C are discussed in this book.

A few wrapper scripts for mysqld come with MySQL. The mysqld_safe script is the most common way to start mysqld , because the script can restart the daemon if it crashes. This helps ensure minimal downtime for database services. The script mysqld_multi is used to start multiple sessions of mysqld_safe , and thereby multiple mysqld instances, for handling requests from different ports and different Unix socket files, and to make it easier to serve different sets of databases. For MS Windows NT and 2000 servers, there's mysqld-nt . It supports the named pipes that some Windows systems use instead of socket files.

MySQL also comes with a variety of utilities for managing a MySQL server. mysqlaccess is used for creating user accounts and setting their privileges. mysqladmin can be used to manage the MySQL server itself from the command line. This interaction includes checking a server's status and usage, and shutting down a server. mysqlshow may be used to examine a server's status, as well as information about databases and tables. Some of these utilities require Perl, or ActivePerl for Windows, to be installed on the server. See http://www.perl.org to download and install a copy of Perl on non-Windows systems, and http://www. activestate .com/Products/ActivePerl to download and install a copy of ActivePerl on Windows systems.

MySQL also comes with a few utilities for importing and exporting data from and to MySQL databases. mysqldump is the most popular for exporting data and table structures to a plain-text file known as a dump file. This can be used for backing up data or for manually moving it between servers. The mysql client can be used to import the data back to MySQL from a dump file.

mysqlhotcopy can also be used to back up a database or specific tables. It's more effective at data consistency between tables than mysqldump , because it locks the tables automatically. The resulting backup files are ready-to-use copies of the databases in the format MySQL uses. To restore them, you can just copy them to MySQL's data directory.

For importing data into MySQL from an external file that was exported in a common database format, MySQL provides mysqlimport .


1.3. Licensing

Although MySQL can be used for free and is open source, MySQL AB holds the copyrights to the source code. The company offers a dual-licensing program for its software: one allows cost-free use through the GPL under certain common circumstances, and the other is a commercial license bearing a fee. They're both the same software, but each has a different license and different privileges. See http://www.fsf.org/licenses for more details on the GPL.

MySQL AB allows you to use the software under the GPL if you use it without redistributing it, or if you redistribute it only with software licensed under the GPL. You can even use the GPL if you redistribute MySQL with software that you developed, as long as you distribute your software under the GPL as well.

However, if you have developed an application that requires MySQL for its functionality and you want to sell your software with MySQL under a nonfree license, you must purchase a commercial license from MySQL AB. There are other scenarios in which a commercial license may be required. For details on when you must purchase a license, see http://www.mysql.com/company/legal/licensing.

Besides holding the software copyrights, MySQL AB also holds the MySQL trademark. As a result, you cannot distribute software that includes MySQL in the name .