Jump to ratings and reviews
Rate this book

MySQL Cookbook: Solutions for Database Developers and Administrators

Rate this book
MySQL’s popularity has brought a flood of questions about how to solve specific problems, and that's where this Cookbook is essential. Designed as a handy resource when you need quick solutions or techniques, the book offers dozens of short, focused pieces of code and hundreds of worked-out examples for programmers of all levels who don't have the time (or expertise) to solve MySQL problems from scratch.

This third edition has been updated to cover new APIs in Python and PHP, as well as powerful new features in MySQL 5.6 and older versions still in common use. Recipes use the mysql client program as well as Java, Perl, PHP, Python, and Ruby APIs.


Set up simple replication scenarios
Sort rows in common ways and use aggregate functions to summarize rows
Find matches or mismatches between rows in two tables
Determine intervals between dates or times, including age calculations
Store images into MySQL and retrieve them for display in web pages
Use strict mode to prevent entry of bad data into your database
Copy a table or a database to another server
Create database events that execute according to a schedule

864 pages, Paperback

First published November 1, 2002

37 people are currently reading
253 people want to read

About the author

Paul DuBois

65 books6 followers
Paul DuBois is the author of MySQL (Addison-Wesley Professional); MySQL Cookbook, Using csh & tcsh, and Software Portability with imake (O'Reilly); and MySQL and Perl for the Web (New Riders).

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
61 (33%)
4 stars
65 (35%)
3 stars
47 (25%)
2 stars
7 (3%)
1 star
2 (1%)
Displaying 1 - 10 of 10 reviews
Profile Image for Matt.
Author 51 books21 followers
October 24, 2007
I rarely read programming books, and even more infrequently have anything nice to say about them. But I found this book to be a great list of recipes, suggestions, and insider's tips for writing good SQL (Standard Query Language -- the language you use to talk to relational databases).

Paul Dubois is a notable expert in the field anyway. If I recall correctly, he's the documentation lead for the MySQL project. Thus, he's certainly well qualified to write something like this.

The tips (or most of them, at least) are highly readable, often practical, and are accompanied with illuminating text (not to be confused with ILLUMINATED text, which would certainly be a first in the programming world).

One thing was noticeably absent, though: tips on tuning queries. Dear Paul Dubois: If you ever read this, please add a section on tuning queries, using EXPLAIN, and improving overall DB performance.
Profile Image for Chris Patterson.
7 reviews1 follower
August 16, 2018
This is my goto book for SQL scripts. If there is an issue I'm having with something deep I can merge the concepts and scripts in this book to get the result I'm looking for.
Profile Image for Michael Milawski.
12 reviews1 follower
June 23, 2022
A good book for mysql. It contains not only many sql queries but also solutions for problems that are not really solvable by sql queries alone, it shows code examples for that matter. It also shows ways of how to configure the server correctly. Very useful book.
12 reviews
April 19, 2010
This is a good reference book containing pre-canned routines for accessing and manipulating a MySQL database. It is a good starting point for making routines to generate reports or validate data.

One other book on my list: MySQL Stored Procedure Programming is a good companion read to this one, as it shows the particulars of how to write logic on the server side. The code in the Cookbook can be used on the server side with ease. The other book also has more advice on how to optimize MySQL code when it does not have satisfactory performance.
Profile Image for Adrian.
12 reviews910 followers
January 29, 2007
A little bland... ba-dump-bump-bing. It had some interesting ideas for monitoring server status programatically, views for summary tables, and gathering stats/logs with triggers. When I do more of those things in detail, I may glance at certain parts again. Available online at Safari Books. [Skimmed w/some reading]
Profile Image for Vaughn.
12 reviews
September 2, 2008
Ha ha, just kidding. But seriously, I am reading this, slowly, for cause, which is the only reason why anyone would...

Update: It did the trick. Quick access to many little tricks that would have taken too much time to think up myself. Sweet. Recommended!
Profile Image for Yuan.
48 reviews
October 4, 2021
Love the structure! It provides you options to go through all the MySql “recipes” quickly and dive into details!
Used the book for repairing technical test interview. Will go through the details to enhance understanding for sure.
Displaying 1 - 10 of 10 reviews

Can't find what you're looking for?

Get help and learn more about the design.