Book Image

MySQL 8 Cookbook

By : Karthik Appigatla
Book Image

MySQL 8 Cookbook

By: Karthik Appigatla

Overview of this book

MySQL is one of the most popular and widely used relational databases in the World today. The recently released MySQL 8 version promises to be better and more efficient than ever before. This book contains everything you need to know to be the go-to person in your organization when it comes to MySQL. Starting with a quick installation and configuration of your MySQL instance, the book quickly jumps into the querying aspects of MySQL. It shows you the newest improvements in MySQL 8 and gives you hands-on experience in managing high-transaction and real-time datasets. If you've already worked with MySQL before and are looking to migrate your application to MySQL 8, this book will also show you how to do that. The book also contains recipes on efficient MySQL administration, with tips on effective user management, data recovery, security, database monitoring, performance tuning, troubleshooting, and more. With quick solutions to common and not-so-common problems you might encounter while working with MySQL 8, the book contains practical tips and tricks to give you the edge over others in designing, developing, and administering your database effectively.
Table of Contents (20 chapters)
Title Page
Dedication
Packt Upsell
Contributors
Preface
Index

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.

Chapter 1, MySQL 8 - Installing and Upgrading, describes how to install MySQL 8 on different flavors of Linux, upgrade to MySQL 8 from previous stable releases, and also downgrade from MySQL 8.

Chapter 2, Using MySQL, takes you through the basic uses of MySQL, such as creating databases and tables; inserting, updating, deleting, and selecting data in various ways; saving to different destinations; sorting and grouping results; joining tables; managing users; other database elements such as triggers, stored procedures, functions, and events; and getting metadata information.

Chapter 3, Using MySQL (Advanced), covers the latest additions to MySQL 8, such as the JSON datatype, common table expressions, and window functions.

Chapter 4, Configuring MySQL, shows you how to configure MySQL and basic configuration parameters.

Chapter 5, Transactions, explains the four isolation levels of RDBMS and how to use MySQL for transactions.

Chapter 6, Binary Logging, demonstrates how to enable binary logging, various formats of binary logs, and how to retrieve data from binary logs.

Chapter 7, Backups, covers various types of backups, the pros and cons of each method, and which one to choose based on your requirements.

Chapter 8, Restoring Data, covers how to recover data from varies backups.

Chapter 9, Replication, explains how to set up various replication topologies. The recipes on switching a slave from master-slave to chain replication and switching a slave from chain replication to master-slave is something that will interest the readers.

Chapter 10, Table Maintenance, covers cloning tables. Managing big tables is something that this chapter will make you a maestro of. Installation and usage of third-party tools is also covered in this chapter.

Chapter 11, Managing Tablespace, deals with recipes that will teach the readers how to resize, create, copy, and manage tablespaces. 

Chapter 12, Managing Logs, takes readers through error, general query, slow query, and binary logs.

Chapter 13, Performance Tuning, explains query and schema tuning in detail. There are ample recipes in the chapter that will cover this.

Chapter 14, Security, focuses on the aspects of security. Recipes on securing installation, restricting networks and users, setting and resetting of passwords, and much more in covered are detail.

To get the most out of this book

Basic knowledge of any Linux system makes it easy for you to understand this book.

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "MySQL has a dependency on the libaio library."

When we wish to draw your attention to a particular part of a command line statement, the relevant lines or items are set in bold:

shell> sudo yum repolist all | grep mysql8
mysql80-community/x86_64             MySQL 8.0 Community Server  enabled:     16
mysql80-community-source             MySQL 8.0 Community Server  disabled

Any command-line input or output is written as follows:

mysql> ALTER TABLE table_name REMOVE PARTITIONING;

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Select the Development Releases tab for getting MySQL 8.0 and the choose the OS and version."

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

Sections

In this book, you will find several headings that appear frequently (Getting ready, How to do it..., How it works..., There's more..., and See also).

To give clear instructions on how to complete a recipe, use these sections as follows:

Getting ready

This section tells you what to expect in the recipe and describes how to set up any software or any preliminary settings required for the recipe.

How to do it…

This section contains the steps required to follow the recipe.

How it works…

This section usually consists of a detailed explanation of what happened in the previous section.

There's more…

This section consists of additional information about the recipe in order to make you more knowledgeable about the recipe.

See also

This section provides helpful links to other useful information for the recipe.

 

Get in touch

Feedback from our readers is always welcome.

General feedback: Email [email protected] and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packtpub.com.