MySQL 8 Cookbook
Over 150 recipes for high-performance database querying and administration
Karthik Appigatla
BIRMINGHAM - MUMBAI
MySQL 8 Cookbook
Copyright 2018 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor: Amey Varangaokar
Acquisition Editor: Viraj Madhav
Content Development Editors: Aishwarya Pandere
Technical Editor: Prasad Ramesh
Copy Editor: Vikrant Phadkay
Project Coordinator: Nidhi Joshi
Proofreader: Safis Editing
Indexer: Pratik Shirodkar
Graphics: Tania Dutta
Production Coordinator: Shraddha Falebhai
First published: January 2018
Production reference: 1230118
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78839-580-9
www.packtpub.com
To my mother, A.S Gayathri, and to the memory of my father, A.S.R.V.S.N Murty, for their sacrifices and for exemplifying the power of determination.
Karthik Appigatla
mapt.io
Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Mapt is fully searchable
Copy and paste, print, and bookmark content
PacktPub.com
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details.
At www.PacktPub.com , you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Contributors
About the author
Karthik Appigatla is a highly reputed database architect and is very famous for performance tuning. He has been consulted by many companies all over the world for designing, performance tuning, building database infrastructure, and training. In his decade of experience, he has worked for companies such as Yahoo, Pythian, and Percona. Currently, he is working for LinkedIn, where he has innovated a new way of analyzing queries. He gave a talk about this at SRECon, Dublin in 2017.
I would like to acknowledge the encouragement from my wife, Lalitha, and my brother, Kashyap. This book would not have completed without the cooperation of my little daughter, Samhita.
About the reviewers
Marco Ippolito is an Italian software engineer working as Director of Software Development for Imagining IT. Marco completed his postgraduate in Software Engineering in Oxford and has worked for large corporations such as Intel, HP, Google, Dell, and Oracle (in the acquired MySQL team), as well as for start-ups such as @platformsh and for large production users of MySQL such as @bookingcom (Twitter). He can be reached at marco.ippolito@imaginingit.com and has experience working in teams speaking Italian, English, Spanish, Brazilian Portuguese, German, and French, remotely or onsite.
Kedar Mohaniraj Vaijanapurkar is a MySQL database consultant with over a decade of experience, ranging from programming to database administration. He aims to spread happiness with the MySQL database systems he works on. Apart from working with MySQL and related open source technologies, he also explores cloud, automation, and NoSQL. He is a 5-year Pythian laureate living with his awesome family in the cultured city of Vadodara, India. You can reach him at kedar@nitty-witty.com.
Packt is searching for authors like you
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Table of Contents
Preface
MySQL is one of the most popular and widely used relational databases in the world today. With the recently released MySQL 8, it promises to be better and more efficient than ever, giving you high-performance querying results and easy configuration as an administrator.
Who this book is for
This book is for a wide range of readers. MySQL database administrators and developers who have worked on earlier versions of MySQL will learn about the features of MySQL 8 and how they can leverage them. For readers who worked on other RDBMSes such as Oracle, MSSQL, PostgreSQL, and Db2 this book will be a quick start guide to MySQL 8. For beginners, this book serves as a handbook; they can refer to the recipes and find quick solutions to their problems.
Most importantly, this book makes you production-ready. After reading this book, you will be confident in handling busy database servers with large datasets.
In my 10 years of experience with MySQL, I have witnessed small mistakes leading to major outages. In this book, many scenarios where a mistake can be made are covered and put under a warning label.
The topics are introduced in such a way that a beginner need not go back and forth to understand the concepts. A reference link to the MySQL documentation or any other source is provided for each topic, and the reader can refer to the link for more details.
Since this book is written to suit beginners as well, there may be a few recipes on topics you already know; feel free to skip them.
What this book covers
Practice makes a man perfect. But to practice, you need some knowledge and training. This book helps you with that. Most day-to-day and practical scenarios are covered in this book.