Book description
The Definitive Guide to Using, Programming, and Administering MySQL 5.0 and 5.1
MySQL is an open source relational database management system that has experienced a phenomenal growth in popularity and use. Known for its speed and ease of use, MySQL has proven itself to be particularly well-suited for developing database-backed websites and applications.
In MySQL, Paul DuBois provides a comprehensive guide to using and administering MySQL effectively and productively. He describes everything from the basics of getting information into a database and formulating queries, to using MySQL with PHP or Perl to generate dynamic web pages, to writing your own programs that access MySQL databases, to administering MySQL servers.
The fourth edition of this bestselling book has been meticulously revised and updated to thoroughly cover the latest features and capabilities of MySQL 5.0, as well as to add new coverage of features introduced with MySQL 5.1.
“One of the best technical books I have read on any subject.”
–Gregory Haley, C Vu, The Association of C & C++ Users
“A top-notch user’s guide and reference manual, and in my opinion, the only book you’ll need for the daily operation and maintenance of MySQL databases.”
–Eugene Kim, Web Techniques
Introduction 1
Part I: General MySQL Use
Chapter 1: Getting Started with MySQL 13
Chapter 2: Using SQL to Manage Data 101
Chapter 3: Data Types 201
Chapter 4: Stored Programs 289
Chapter 5: Query Optimization 303
Part II: Using MySQL Programming Interfaces
Chapter 6: Introduction to MySQL Programming 341
Chapter 7: Writing MySQL Programs Using C 359
Chapter 8: Writing MySQL Programs Using Perl DBI 435
Chapter 9: Writing MySQL Programs Using PHP 527
Part III: MySQL Administration
Chapter 10: Introduction to MySQL Administration 579
Chapter 11: The MySQL Data Directory 585
Chapter 12: General MySQL Administration 609
Chapter 13: Access Control and Security 699
Chapter 14: Database Maintenance, Backups, and Replication 737
Part IV: Appendixes
Appendix A: Obtaining and Installing Software 777
Appendix B: Data Type Reference 797
Appendix C: Operator and Function Reference 813
Appendix D: System, Status, and User Variable Reference 889
Appendix E: SQL Syntax Reference 937
Appendix F: MySQL Program Reference 1037
Note:Appendixes G, H, and I are located online and are accessible either by registering this book at informit.com/register or by visiting www.kitebird.com/mysql-book.
Appendix G: C API Reference 1121
Appendix H: Perl DBI API Reference 1177
Appendix I: PHP API Reference 1207
Index 1225
Table of contents
- Copyright
- Developer’s Library
- About the Author
- Acknowledgments
- We Want to Hear from You!
- Reader Services
- Introduction
-
I. General MySQL Use
-
1. Getting Started with MySQL
- 1.1. How MySQL Can Help You
- 1.2. A Sample Database
- 1.3. Basic Database Terminology
-
1.4. A MySQL Tutorial
- 1.4.1. Obtaining the Sample Database Distribution
- 1.4.2. Preliminary Requirements
- 1.4.3. Establishing and Terminating Connections to the MySQL Server
- 1.4.4. Executing SQL Statements
- 1.4.5. Creating a Database
- 1.4.6. Creating Tables
- 1.4.7. Adding New Rows
- 1.4.8. Resetting the sampdb Database to a Known State
-
1.4.9. Retrieving Information
- 1.4.9.1. Specifying Retrieval Criteria
- 1.4.9.2. The NULL Value
- 1.4.9.3. Sorting Query Results
- 1.4.9.4. Limiting Query Results
- 1.4.9.5. Calculating and Naming Output Column Values
- 1.4.9.6. Working with Dates
- 1.4.9.7. Pattern Matching
- 1.4.9.8. Setting and Using User-Defined Variables
- 1.4.9.9. Generating Summaries
- 1.4.9.10. Retrieving Information from Multiple Tables
- 1.4.10. Deleting or Updating Existing Rows
- 1.5. Tips for Interacting with mysql
- 1.6. Where to Now?
-
2. Using SQL to Manage Data
- 2.1. The Server SQL Mode
- 2.2. MySQL Identifier Syntax and Naming Rules
- 2.3. Case Sensitivity in SQL Statements
- 2.4. Character Set Support
- 2.5. Selecting, Creating, Dropping, and Altering Databases
-
2.6. Creating, Dropping, Indexing, and Altering Tables
-
2.6.1. Storage Engine Characteristics
- 2.6.1.1. Checking Which Storage Engines Are Available
- 2.6.1.2. Table Representation on Disk
- 2.6.1.3. The MyISAM Storage Engine
- 2.6.1.4. The MERGE Storage Engine
- 2.6.1.5. The MEMORY Storage Engine
- 2.6.1.6. The InnoDB Storage Engine
- 2.6.1.7. The Falcon Storage Engine
- 2.6.1.8. The FEDERATED Storage Engine
- 2.6.1.9. The NDB Storage Engine
- 2.6.1.10. Other Storage Engines
- 2.6.1.11. Storage Engine Portability Characteristics
- 2.6.2. Creating Tables
- 2.6.3. Dropping Tables
- 2.6.4. Indexing Tables
- 2.6.5. Altering Table Structure
-
2.6.1. Storage Engine Characteristics
- 2.7. Obtaining Database Metadata
- 2.8. Performing Multiple-Table Retrievals with Joins
- 2.9. Performing Multiple-Table Retrievals with Subqueries
- 2.10. Performing Multiple-Table Retrievals with UNION
- 2.11. Using Views
- 2.12. Multiple-Table Deletes and Updates
- 2.13. Performing Transactions
- 2.14. Foreign Keys and Referential Integrity
- 2.15. Using FULLTEXT Searches
-
3. Data Types
- 3.1. Data Value Categories
- 3.2. MySQL Data Types
- 3.3. How MySQL Handles Invalid Data Values
- 3.4. Working with Sequences
- 3.5. Expression Evaluation and Type Conversion
- 3.6. Choosing Data Types
- 4. Stored Programs
- 5. Query Optimization
-
1. Getting Started with MySQL
-
II. Using MySQL Programming Interfaces
- 6. Introduction to MySQL Programming
-
7. Writing MySQL Programs Using C
- 7.1. Compiling and Linking Client Programs
- 7.2. Connecting to the Server
- 7.3. Handling Errors and Processing Command Options
-
7.4. Processing SQL Statements
- 7.4.1. Handling Statements That Modify Rows
- 7.4.2. Handling Statements That Return a Result Set
- 7.4.3. A General-Purpose Statement Handler
- 7.4.4. Alternative Approaches to Statement Processing
- 7.4.5. mysql_store_result() Versus mysql_use_result()
- 7.4.6. Using Result Set Metadata
- 7.4.7. Encoding Special Characters and Binary Data
- 7.5. An Interactive Statement-Execution Program
- 7.6. Writing Clients That Include SSL Support
- 7.7. Using the Embedded Server Library
- 7.8. Using Multiple-Statement Execution
- 7.9. Using Server-Side Prepared Statements
-
8. Writing MySQL Programs Using Perl DBI
- 8.1. Perl Script Characteristics
-
8.2. Perl DBI Overview
- 8.2.1. DBI Data Types
- 8.2.2. A Simple DBI Script
- 8.2.3. Handling Errors
- 8.2.4. Handling Statements That Modify Rows
- 8.2.5. Handling Statements That Return a Result Set
- 8.2.6. Quoting Special Characters in Statement Strings
- 8.2.7. Placeholders and Prepared Statements
- 8.2.8. Binding Query Results to Script Variables
- 8.2.9. Specifying Connection Parameters
- 8.2.10. Debugging
- 8.2.11. Using Result Set Metadata
- 8.2.12. Performing Transactions
- 8.3. Putting DBI to Work
- 8.4. Using DBI in Web Applications
-
9. Writing MySQL Programs Using PHP
-
9.1. PHP Overview
- 9.1.1. A Simple PHP Script
- 9.1.2. Using PHP Library Files for Code Encapsulation
- 9.1.3. A Simple Data-Retrieval Page
- 9.1.4. Processing Statement Results
- 9.1.5. Testing for NULL Values in Query Results
- 9.1.6. Using Prepared Statements
- 9.1.7. Using Placeholders to Handle Data Quoting Issues
- 9.1.8. Handling Errors
- 9.2. Putting PHP to Work
-
9.1. PHP Overview
-
III. MySQL Administration
- 10. Introduction to MySQL Administration
-
11. The MySQL Data Directory
- 11.1. Location of the Data Directory
-
11.2. Structure of the Data Directory
- 11.2.1. How the MySQL Server Provides Access to Data
- 11.2.2. Representation of Databases in the Filesystem
- 11.2.3. Representation of Tables in the Filesystem
- 11.2.4. Representation of Views and Triggers in the Filesystem
- 11.2.5. How SQL Statements Map onto Table File Operations
- 11.2.6. Operating System Constraints on Database Object Names
- 11.2.7. Factors That Affect Maximum Table Size
- 11.2.8. Implications of Data Directory Structure for System Performance
- 11.2.9. MySQL Status and Log Files
-
11.3. Relocating Data Directory Contents
- 11.3.1. Relocation Methods
- 11.3.2. Relocation Precautions
- 11.3.3. Assessing the Effect of Relocation
- 11.3.4. Relocating the Entire Data Directory
- 11.3.5. Relocating Individual Databases
- 11.3.6. Relocating Individual Tables
- 11.3.7. Relocating the InnoDB Shared Tablespace
- 11.3.8. Relocating Status and Log Files
-
12. General MySQL Administration
- 12.1. Securing a New MySQL Installation
- 12.2. Arranging for MySQL Server Startup and Shutdown
- 12.3. Controlling How the Server Listens for Connections
- 12.4. Managing MySQL User Accounts
- 12.5. Maintaining Logs
- 12.6. Tuning the Server
- 12.7. Storage Engine Configuration
- 12.8. Enabling or Disabling LOCAL Capability for LOAD DATA
- 12.9. Internationalization and Localization Issues
- 12.10. Running Multiple Servers
- 12.11. Updating MySQL
-
13. Access Control and Security
- 13.1. Internal Security: Preventing Unauthorized Filesystem Access
-
13.2. External Security: Preventing Unauthorized Network Access
-
13.2.1. Structure and Contents of the MySQL Grant Tables
- 13.2.1.1. Grant Table Scope-of-Access Columns
- 13.2.1.2. Grant Table Privilege Columns
- 13.2.1.3. Administrative Privileges
- 13.2.1.4. Database and Table Privileges
- 13.2.1.5. How the Grant Tables Represent Privileges
- 13.2.1.6. Grant Table SSL-Related Columns
- 13.2.1.7. Grant Table Resource Management Columns
- 13.2.2. How the Server Controls Client Access
- 13.2.3. A Privilege Puzzle
- 13.2.4. Grant Table Risks to Avoid
-
13.2.1. Structure and Contents of the MySQL Grant Tables
- 13.3. Setting Up Secure Connections
-
14. Database Maintenance, Backups, and Replication
- 14.1. Principles of Preventive Maintenance
- 14.2. Performing Database Maintenance with the Server Running
- 14.3. General Preventative Maintenance
- 14.4. Making Database Backups
- 14.5. Copying Databases to Another Server
- 14.6. Checking and Repairing Database Tables
- 14.7. Using Backups for Data Recovery
- 14.8. Setting Up Replication Servers
-
IV. Appendixes
-
A. Obtaining and Installing Software
- A.1. Obtaining the sampdb Sample Database Distribution
- A.2. Obtaining MySQL and Related Software
- A.3. Choosing a Version of MySQL
- A.4. Installing MySQL on Unix
- A.5. Installing MySQL on Windows
- B. Data Type Reference
-
C. Operator and Function Reference
- C.1. Operators
-
C.2. Functions
- C.2.1. Comparison Functions
- C.2.2. Cast Functions
- C.2.3. Numeric Functions
- C.2.4. String Functions
- C.2.5. Date and Time Functions
- C.2.6. Summary Functions
- C.2.7. Security and Compression Functions
- C.2.8. Advisory Locking Functions
- C.2.9. Spatial Functions
- C.2.10. XML Functions
- C.2.11. Miscellaneous Functions
- D. System, Status, and User Variable Reference
-
E. SQL Syntax Reference
-
E.1. SQL Statement Syntax (Non-Compound Statements)
- ALTER DATABASE
- ALTER EVENT
- ALTER FUNCTION, ALTER PROCEDURE
- ALTER SERVER
- ALTER TABLE
- ALTER VIEW
- ANALYZE TABLE
- BEGIN
- CACHE INDEX
- CALL
- CHANGE MASTER
- CHECK TABLE
- CHECKSUM TABLE
- COMMIT
- CREATE DATABASE
- CREATE EVENT
- CREATE FUNCTION, CREATE PROCEDURE
- CREATE INDEX
- CREATE SERVER
- CREATE TABLE
- CREATE TRIGGER
- CREATE USER
- CREATE VIEW
- DEALLOCATE PREPARE
- DELETE
- DESCRIBE
- DO
- DROP DATABASE
- DROP EVENT
- DROP FUNCTION, DROP PROCEDURE
- DROP INDEX
- DROP SERVER
- DROP TABLE
- DROP TRIGGER
- DROP USER
- DROP VIEW
- EXECUTE
- EXPLAIN
- FLUSH
- GRANT
- HANDLER
- INSERT
- KILL
- LOAD DATA
- LOAD INDEX INTO CACHE
- LOCK TABLE
- OPTIMIZE TABLE
- PREPARE
- PURGE MASTER LOGS
- RELEASE SAVEPOINT
- RENAME TABLE
- RENAME USER
- REPAIR TABLE
- REPLACE
- RESET
- REVOKE
- ROLLBACK
- SAVEPOINT
- SELECT
- SET
- SET PASSWORD
- SET TRANSACTION
- SHOW
- SHOW BINLOG EVENTS
- SHOW CHARACTER SET
- SHOW COLLATION
- SHOW COLUMNS
- SHOW CREATE
- SHOW DATABASES
- SHOW ENGINE
- SHOW ENGINES
- SHOW ERRORS
- SHOW EVENTS
- SHOW FUNCTION STATUS, SHOW PROCEDURE STATUS
- SHOW GRANTS
- SHOW INDEX
- SHOW INNODB STATUS
- SHOW MASTER LOGS
- SHOW MASTER STATUS
- SHOW MUTEX STATUS
- SHOW OPEN TABLES
- SHOW PRIVILEGES
- SHOW PROCESSLIST
- SHOW SLAVE HOSTS
- SHOW SLAVE STATUS
- SHOW STATUS
- SHOW TABLE STATUS
- SHOW TABLE TYPES
- SHOW TABLES
- SHOW TRIGGERS
- SHOW VARIABLES
- SHOW WARNINGS
- START SLAVE
- START TRANSACTION
- STOP SLAVE
- TRUNCATE
- UNION
- UNLOCK TABLE
- UPDATE
- USE
- E.2. Compound Statement Syntax
- E.3. Comment Syntax
-
E.1. SQL Statement Syntax (Non-Compound Statements)
-
F. MySQL Program Reference
- F.1. Displaying a Program’s Help Message
- F.2. Specifying Program Options
- F.3. myisamchk
- F.4. myisampack
- F.5. mysql
- F.6. mysql.server
- F.7. mysql_config
- F.8. mysql_install_db
- F.9. mysqladmin
- F.10. mysqlbinlog
- F.11. mysqlcheck
- F.12. mysqld
- F.13. mysqld_multi
- F.14. mysqld_safe
- F.15. mysqldump
- F.16. mysqlhotcopy
- F.17. mysqlimport
- F.18. mysqlshow
- F.19. perror
-
G. C API Reference
- G.1. Compiling and Linking
- G.2. C API Data Types
-
G.3. C API Functions
- G.3.1. Client Library Initialization and Termination Routines
- G.3.2. Connection Management Routines
- G.3.3. Error-Reporting Routines
- G.3.4. Statement Construction and Execution Routines
- G.3.5. Result Set Processing Routines
- G.3.6. Information Routines
- G.3.7. Transaction Control Routines
- G.3.8. Multiple Result Set Routines
- G.3.9. Prepared Statement Routines
- G.3.10. Administrative Routines
- G.3.11. Threaded Client Routines
- G.3.12. Debugging Routines
- H. Perl DBI API Reference
- I. PHP API Reference
-
A. Obtaining and Installing Software
Product information
- Title: MySQL®
- Author(s):
- Release date: August 2008
- Publisher(s): Addison-Wesley Professional
- ISBN: 9780768678673
You might also like
book
MySQL
The authoritative, hands-on guide to advanced MySQL programming and administration techniques for high performance is here. …
book
Head First Design Patterns, 2nd Edition
You know you don’t want to reinvent the wheel, so you look to design patterns—the lessons …
book
Fundamentals of Software Architecture
Salary surveys worldwide regularly place software architect in the top 10 best jobs, yet no real …
book
MySQL, Fifth Edition
MySQL, Fifth Edition by Paul DuBois The definitive guide to using, programming and administering MySQL 5.5 …