Praise for Learning MySQL, Second Edition
Its been a long time since a good book covering MySQL and its ecosystem has been published, and many changes have occurred since then. Many topics are clearly covered with examples, from installation and database design to maintenance and architecture for HA and cloud. Many third-party tools are also covered, like dbdeployer and ProxySQL, which are MySQL DBAs very good friends but are often not covered in the literature. Very nice job from Vinicius and Sergey. Dont miss the last chapterits very interesting!
Frederic Descamps, MySQL evangelist at Oracle
First of all, I want to thank Vinicius and Sergey for making possible my dream book for all beginners of MySQL while I work on the developer edition. This book offers the most comprehensive details on MySQL, not only how to get started but also for complex topics like high availability and load balancing. Its a smooth read with well-organized content befitting the quality of OReilly publishing. I highly recommend this book to all readers, from developers to operations.
Alkin Tezuysal, senior technical manager at PlanetScale
This book is a terrific resource, whether youre installing MySQL for the first time, learning load balancing, or migrating your database
to the cloud. I highly recommend it.
Brett Holleman, software engineer
This book is essential for anyone who wants to dive into the MySQL ecosystem. With clear and objective communication, it covers topics from basic to advanced. Simply an indispensable book to increase MySQL knowledge.
Diego Hellas, CEO, PerformanceDB
Walks the reader through all the important MySQL concepts, from the foundation of SQL and data modeling to advanced topics like high availability and cloud, using clear, concise, direct language.
Charly Batista, Percona
Learning MySQL
by Vinicius M. Grippa and Sergey Kuzmichev
Copyright 2021 Vinicius M. Grippa and Sergey Kuzmichev. All rights reserved.
Printed in the United States of America.
Published by OReilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .
- Acquisitions Editor: Andy Kwan
- Development Editor: Corbin Collins
- Production Editor: Beth Kelly
- Copyeditor: Rachel Head
- Proofreader: Kim Wimpsett
- Indexer: Sue Klefstad
- Interior Designer: David Futato
- Cover Designer: Karen Montgomery
- Illustrator: Kate Dullea
- November 2006: First Edition
- September 2021: Second Edition
Revision History for the Second Edition
- 2021-09-09: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781492085928 for release details.
The OReilly logo is a registered trademark of OReilly Media, Inc. Learning MySQL, the cover image, and related trade dress are trademarks of OReilly Media, Inc.
The views expressed in this work are those of the authors, and do not represent the publishers views. While the publisher and the authors have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the authors disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
978-1-492-08592-8
[LSI]
Preface
Database management systems are part of the core of many companies. Even if a business is not technology-focused, it needs to store, access, and manipulate data in a fast, secure, and reliable way. Because of the COVID-19 pandemic, many areas that had traditionally resisted digital transformation, like the judiciary systems in many countries, are now being integrated through technology due to travel and meeting restrictions, and online shopping and working from home are more popular than ever before.
But its not just disasters that have propelled such far-reaching changes. With the advent of 5G, we will soon have many more machines connected to the internet than humans. Vast amounts of data are already being harvested, stored, and used to train machine learning models, artificial intelligence, and much more. We are living at the beginning of the next revolution.
Several database types have emerged to help with the mission of storing more dataespecially unstructured dataincluding NoSQL databases like MongoDB, Cassandra, and Redis. However, traditional SQL databases remain popular, and there is no sign that they will vanish in the near future. And in the SQL world, undoubtedly the most popular open source solution is MySQL.
Both of the authors of this book have worked with many customers from all parts of the world. Along the way, we have learned lots of lessons and experienced a vast number of use cases, ranging from mission-critical monolith applications to simpler microservices applications. This book is full of the tips and advice we think most readers will find helpful for their daily activities.
Who This Book Is For
This book is primarily for people using MySQL for the first time or learning it as a second database. If you are entering the database arena for the first time, the first chapters will introduce you to the database design concepts and show you how to deploy MySQL into different operating systems and in the cloud.
For those coming from another ecosystem, like Postgres, Oracle, or SQL Server, the book covers backup, high availability, and disaster recovery strategies.
We hope all readers will also find this book to be a good companion for learning or reviewing fundamentals, from the architecture to advice for the production environment.
How This Book Is Organized
We introduce many topics, from the basic installation process, database design, backups, and recovery to CPU performance analysis and bug investigation. Weve divided the book into four main parts:
Starting with MySQL
Using MySQL
MySQL in Production
Miscellaneous Topics
Lets look at how weve organized the chapters.
Starting with MySQL
explains how to install and configure the MySQL software on different operating systems. This chapter provides far more detail than most books do. We know that those initiating their career with MySQL are often unfamiliar with various Linux distributions and installation options, and running the MySQL hello world requires far more steps than compiling a hello world in any programming language does. You will see how to set up MySQL on Linux, Windows, macOS, and Docker, and how to deploy instances quickly for testing.
Using MySQL
Before we dive into creating and using databases, we look at proper database design in . You will learn how to access your databases features and see how the information items in your database relate to each other. You will see that lousy database designs are challenging to change and can lead to performance problems. We will introduce the concept of strong and weak entities and their relationships (