MySQL Utilities

MySQL Utilities

Abstract

This is the MySQLTM Utilities Reference Manual. It documents both the GPL and commercial editions of the MySQL Utilities 1.5 release series through 1.5.6.

If you have not yet installed MySQL Utilities please download your free copy from the download site. MySQL Utilities is available for Windows, OS X, and Linux variants.

For notes detailing the changes in each release, see the MySQL Utilities Release Notes.

For legal information, see the Legal Notices.

For help with using MySQL, please visit either the MySQL Forums or MySQL Mailing Lists, where you can discuss your issues with other MySQL users.

Licensing information. This product may include third-party software, used under license. If you are using a Commercial release of MySQL Utilities, see the MySQL Utilities Commercial License Information User Manual for licensing information, including licensing information relating to third-party software that may be included in this Commercial release. If you are using a Community release of MySQL Utilities, see the MySQL Utilities Community License Information User Manual for licensing information, including licensing information relating to third-party software that may be included in this Community release.

Document generated on: 2018-06-28 (revision: 57918)

Table of Contents

Preface ......................................................................................................................................... v 1 How to Install MySQL Utilities .................................................................................................... 1

1.1 Prerequisites ................................................................................................................... 1 1.2 Source Code .................................................................................................................. 1 1.3 Oracle Linux and Red Hat Linux 6 ................................................................................... 2 1.4 Debian Linux .................................................................................................................. 2 1.5 Microsoft Windows .......................................................................................................... 2 1.6 OS X .............................................................................................................................. 3 2 Introduction ............................................................................................................................... 5 2.1 Introduction to MySQL Utilities ........................................................................................ 5 2.2 Connecting to MySQL Servers ........................................................................................ 6

2.2.1 Connection Parameters ........................................................................................ 6 2.2.2 Specifying Connections in Python Library .............................................................. 9 3 MySQL Utilities Administrative Tasks ........................................................................................ 13 3.1 Database Operations .................................................................................................... 13 3.1.1 How do you provision a slave? ........................................................................... 14 3.1.2 How do you make a copy of a database on the same server? ............................... 15 3.1.3 How can you make a copy of a database and change the storage engine? ............ 16 3.1.4 How do you tell if a table on server A has the same structure as the same table on server B? ............................................................................................................... 18 3.1.5 How do you synchronize a table on two servers where neither is up-to-date? ......... 19 3.2 General Operations ....................................................................................................... 20 3.2.1 How do you know how much space your data uses? ........................................... 20 3.2.2 How do you recover the CREATE statement from a damaged or offline server? ...... 21 3.2.3 How do you create a new user with the same privileges as another user? .............. 23 3.2.4 Is there an easy way to know what options are used with each utility? ................... 24 3.2.5 How do you find redundant or duplicate indexes and know which ones to drop? ...... 27 3.2.6 How do you find all objects that start with a given name prefix? ............................ 29 3.2.7 How do you run a process every night to kill certain connections? ......................... 30 3.3 High Availability Operations ........................................................................................... 31 3.3.1 How do you setup and use replication? ............................................................... 31 3.3.2 How do you add new servers to an existing topology and change the master role? ........................................................................................................................... 33 3.3.3 How do you setup and use automatic failover? .................................................... 35 3.3.4 How do you restore the previous master to service after failover? ......................... 38 3.3.5 How do you find all of the slaves attached to a master server? ............................. 41 3.3.6 How Can you determine if data was replicated correctly? ..................................... 42 3.3.7 How do you fix errant transactions on the replication topology? ............................. 44 3.4 Server Operations ......................................................................................................... 45 3.4.1 How can you create a temporary copy (running instance) of a server for testing? .... 45 3.4.2 How do you find what MySQL servers are running on a local machine? ................. 47 3.4.3 How do you setup and use a secure (encrypted) connection between Utilities and a MySQL server? ........................................................................................................ 48 3.5 Specialized Operations .................................................................................................. 52 3.5.1 How do you record only login events in the audit log? .......................................... 52 3.5.2 How do you copy or move the audit log? ............................................................ 54 3.5.3 How can you find the INSERT and UPDATE queries that failed in the audit log? ..... 55 3.5.4 How do you find connections by the user 'root' in the audit log and show the results in CSV format? ................................................................................................ 56 4 Overview of MySQL Utilities ..................................................................................................... 59 4.1 Database Operations .................................................................................................... 59 4.2 General Operations ....................................................................................................... 59 4.3 High Availability Operations ........................................................................................... 60 4.4 Server Operations ......................................................................................................... 61 4.5 Specialized Operations .................................................................................................. 61

iii

MySQL Utilities

5 Manual Pages ......................................................................................................................... 63 5.1 mysqlauditadmin -- Allows users to perform maintenance actions on the audit log ....... 63 5.2 mysqlauditgrep -- Allows users to search the current or an archived audit log ............. 68 5.3 mysqldbcompare -- Compare Two Databases and Identify Differences ......................... 75 5.4 mysqldbcopy -- Copy Database Objects Between Servers ........................................... 84 5.5 mysqldbexport -- Export Object Definitions or Data from a Database .......................... 91 5.6 mysqldbimport -- Import Object Definitions or Data into a Database ............................ 99 5.7 mysqldiff -- Identify Differences Among Database Objects ....................................... 104 5.8 mysqldiskusage -- Show Database Disk Usage ....................................................... 109 5.9 mysqlfailover -- Automatic replication health monitoring and failover ....................... 113 5.10 mysqlfrm -- File reader for .frm files. ....................................................................... 123 5.11 mysqlindexcheck -- Identify Potentially Redundant Table Indexes ........................... 127 5.12 mysqlmetagrep -- Search Database Object Definitions ............................................ 131 5.13 mysqlprocgrep -- Search Server Process Lists ....................................................... 135 5.14 mysqlreplicate -- Set Up and Start Replication Between Two Servers .................... 139 5.15 mysqlrplms -- Set Up and Start Replication from a Slave to Multiple Masters ............. 143 5.16 mysqlrpladmin -- Administration utility for MySQL replication .................................. 148 5.17 mysqlrplcheck -- Check Replication Prerequisites .................................................. 158 5.18 mysqlrplshow -- Show Slaves for Master Server ..................................................... 163 5.19 mysqlrplsync -- Replication synchronization checker .............................................. 167 5.20 mysqlserverclone -- Clone Existing Server to Create New Server .......................... 174 5.21 mysqlserverinfo -- Display Common Diagnostic Information from a Server ............. 176 5.22 mysqluc -- Command line client for running MySQL Utilities ...................................... 180 5.23 mysqluserclone -- Clone Existing User to Create New User ................................... 183

6 Extending MySQL Utilities ...................................................................................................... 187 6.1 Introduction to extending the MySQL Utilities ................................................................ 187 6.2 MySQL Utilities copy_server.py sample ........................................................................ 193 6.3 Specialized Operations ................................................................................................ 195 6.3.1 mysql.mand.grep -- Search Databases for Objects .............. 195 6.3.2 mysql.mand.proc -- Search Processes on Servers .............. 197 6.4 Parsers ....................................................................................................................... 198 6.4.1 mysql.utilities.parser -- Parse MySQL Log Files ................................................ 198

7 MySQL Utilities Testing (MUT) ............................................................................................... 203 7.1 mut -- MySQL Utilities Testing .................................................................................... 203

8 Appendix ............................................................................................................................... 207 8.1 MySQL Utilities Frequently Asked Questions ................................................................ 207

Index ........................................................................................................................................ 209

iv

Preface

This is the User Manual for the MySQL Utilities.

MySQL Utilities is both a set of command-line utilities as well as a Python library for making common DevOps tasks easy to accomplish. The library is written entirely in Python, meaning that it is not necessary to have any other tools or libraries installed to make it work. It is currently designed to work with Python v2.6 or later and there is no support (yet) for Python v3.1.

Layout

This manual is arranged in an order designed to provide a quick reference for how to use MySQL Utilities. It begins with a brief introduction of MySQL Utilities then presents a list of common administration tasks with examples of how utilities can be used to perform the tasks. From there, the manual begins a deeper dive into the utilities starting with overviews of each utility leading to a detailed description of each via a manual page format. Thus, the manual provides a documentation solution for several needs.

How to Use This Manual

You can use this manual to get a quick solution to an administrative task complete with explanation of how to run the utilities involved and the options and parameters needed. See the tasks chapter for this information.

You can use the manual to learn what utilities exist and how each fits into your own administrative needs. See the utility overview chapter for this information.

You can also use the manual to get more information about each utility and what each option and parameter does via the manuals section.

The manual concludes with a look at extending the MySQL Utilities library, a look at the developer testing environment, and a list of frequently asked questions.

Legal Notices

Copyright ? 2006, 2018, Oracle and/or its affiliates. All rights reserved.

This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.

The information contained herein is subject to change without notice and is not warranted to be errorfree. If you find any errors, please report them to us in writing.

If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable:

U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are "commercial computer software" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, shall be subject to license terms and license restrictions applicable to the programs. No other rights are granted to the U.S. Government.

v

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download