Preface

MySQL is the most popular open source database system available. It’s particularly useful for public websites that require a fast and stable database. Even if you’re not familiar with MySQL, you’ve used it many times. You use it when you use Google, Amazon, Facebook, Wikipedia, and many other popular websites. It’s the keeper of the data behind huge websites with thousands of pages of data, and small sites with only a few pages. It’s also used in many non-web-based applications. It’s fast, stable, and small when needed.

The software was started by Michael “Monty” Widenius and David Axmark in 1995 and is licensed under the GNU General Public License. In time, they founded the Swedish company MySQL Ab (the Ab stands for aktiebolag, or stock company), which years later became MySQL, Inc., incorporated in the United States. In January 2008, the company was acquired by Sun Microsystems, which seemed promising for the future of the software. But in April 2009 Oracle—a major competitor of MySQL that offers closed source database software—acquired Sun. Many worried at the time that this acquisition would eventually end MySQL software as a free, open source alternative on which much of the Web and many sites that have changed the world were built. Five years after the acquisition, this hasn’t proved to be the case. Many new features have been added to MySQL and the number of MySQL developers within and outside of Oracle has increased.

Displeased that Oracle took control of MySQL software, Monty started a new company (Monty Program Ab) that has developed a fork of the software called MariaDB.[1] Because MySQL software is licensed with the GPL, it is possible to freely and legally use the MySQL software and add to it. At the same time, Ulf Sandberg, the former Senior Vice President of Services at MySQL, Inc., along with other former employees of MySQL, left Sun and Oracle and started SkySQL Ab, providing support, consulting, training, and other services related to MySQL and MariaDB software. As of October 2013, Monty Program has merged into SkySQL, which was renamed to MariaDB Ab in October 2014. The software license, though, is now held by the MariaDB Foundation so that it cannot be bought by Oracle or any other corporation.

As for the community related to the software, some have been migrating to MariaDB, preferring software not associated with a large proprietary software company. Many operating systems distributors, hardware makers, and software packagers are now shipping their products with MariaDB, either together with MySQL or without it. Many websites that used MySQL software have switched to MariaDB. It’s easy to do, and for most sites it requires no changes to applications that use MySQL—not a single line of code needs to be changed to switch to MariaDB. If you want to take advantage of new, advanced features of MariaDB, it is necessary to add or change code in an application that previously used MySQL, bu the rest is the same.

Although ownership, company names, and even the name of the software has changed, the vision that began almost 30 years ago and the spirit that has grown strong and vibrant in the community is the same and continues in MariaDB.

If you want to learn about MySQL and MariaDB software, you can do it. It’s not difficult to understand or to use. This book has been written to be a primer for newcomers to MySQL and MariaDB, to get you started and help you be productive quickly. It’s also useful for beginners who have learned only parts of MySQL and feel that there may be key aspects used commonly that they don’t know, that they somehow missed or skipped over when first learning it. At the beginner level, there is no difference between MySQL and MariaDB. So when you learn one, you learn the other. Because of this, the names MySQL and MariaDB are used interchangeably.

Reading Strategy

The chapters of this book are written and ordered based on the assumption that the reader will read them in order. This does not assume that some chapters won’t be skipped; it’s assumed that most will skip Part I. For instance, in addition to skipping Chapter 1, the introductory chapter, if MySQL is already installed on your computer, you would probably skip Chapter 2, which covers installing MySQL and MariaDB. If you’ve never used MySQL, you probably should read Chapter 3, The Basics and the mysql Client. After that, all readers should read sequentially the chapters contained in the Parts II, III, and IV. The remaining chapters, contained in Part V, relate to administration and not all of those may be of use to you early on.

Most of the chapters conclude with a set of exercises. The exercises are designed to help you think through what you’ve read in the chapter. Working through the exercises will help reinforce what you should have learned from the examples in the chapter. Incidentally, it’s useful to try entering the examples throughout the chapters for more practice. The exercises at the end of the chapters depend on a building of knowledge, if not from one chapter to the next, at least from previous chapters.

Text-Based Interface and Operating Systems

Many people feel that graphical user interfaces (GUIs) are faster when using a complex software program or system. This accounts for the popularity of Windows programs. However, while it is said that a picture is worth a thousand words, when you want to say only one word, you don’t need to draw a picture. You don’t need to use an elaborate GUI to make a minute change to a database.

In particular, I don’t like GUIs for controlling a server or MySQL. Interfaces tend to change between versions of the interface. Command-line utilities are very stable and their basic commands don’t usually change. If you know how to configure a server at the command line, it matters little what kind of server you’re entering commands on. Any examples in this book that are executed within MySQL are universal. Examples shown at the command line are for Unix-like operating systems (e.g., Linux). I leave it to readers to make the necessary adjustments for their particular operating systems (i.e., how to get to the command prompt).

Conventions Used in This Book

The following typographical conventions are used in this book:

Italic

Indicates new terms, URLs, email addresses, filenames, and file extensions.

Constant width

Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.

Constant width bold

Shows commands or other text that should be typed literally by the user.

Constant width italic

Shows text that should be replaced with user-supplied values or by values determined by context.

Tip

This icon signifies a tip, suggestion, or general note.

Caution

This icon indicates a warning or caution.

Using Code Examples

All of the scripts and programs shown in the book are available for you to easily copy and modify for your own use. They can be found on the Web at http://mysqlresources.com/files.

This book is here to help you learn MySQL and MariaDB and to get your job done in relation to this software. In general, if this book includes code examples, you may use the code in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Learning MySQL and MariaDB by Russell J.T. Dyer (O’Reilly). Copyright 2015 Russell J.T. Dyer, 978-1-449-36290-4.”

If you feel your use of code examples falls outside fair use or the permission given above, you may contact us at to request special permission.

Safari® Books Online

Note

Safari Books Online is an on-demand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business.

Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.

Safari Books Online offers a range of plans and pricing for enterprise, government, education, and individuals.

Members have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and hundreds more. For more information about Safari Books Online, please visit us online.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at http://bit.ly/lrng_mysql_and_mariadb.

To comment or ask technical questions about this book, send email to .

For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.

Find us on Facebook: http://facebook.com/oreilly

Follow us on Twitter: http://twitter.com/oreillymedia

Watch us on YouTube: http://www.youtube.com/oreillymedia

Acknowledgments

Thanks to my colleagues Colin Charles, Kenneth Dyer, Chad Hudson, Caryn-Amy Rose, and Sveta Smirnova for reviewing this book for technical accuracy and for advice and other information critical to its creation. Thanks to my editor, Andy Oram, for his help and his confidence in me over the many years I’ve known him. Thanks to my two bosses from the MySQL and MariaDB world: Ulf Sandberg and Max Mether, both of whom worked at MySQL AB and SkySQL/MariaDB Ab. Both of them have been very encouraging and excellent managers. Thanks also to my friend and coworker, Rusty Osborne Johnson for her friendship and patience while working on this book.



[1] Incidentally, MySQL is named for Monty Widenius’ first daughter, My Widenius. MariaDB is named for his second daughter, Maria Widenius.

Get Learning MySQL and MariaDB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.