SlideShare une entreprise Scribd logo
1  sur  42
The MySQL Utilities
Cools tools for you
Dave Stokes - MySQL Community Manager
David.Stokes@Oracle.Com
@Stoker
slideshare.net/davidmstokes
Elephantanddolphin.blogger.com or opensourcedba.wordpress.com
2
21 Years Old
MySQL has been part of
Oracle’s family of databases
for six years.
MySQL 8
MySQl 5.7 is the current release
but the next version will be
MySQL 8. Big feature is real
time data dictionary
Group Replication
Active master-master
replication.
JSON
A new native JSON datatype to
store documents in a column of
a table
Document Store
Programmers not know SQL
but need a database? X Devapi
allows them to use RDMS from
language of choice
Encryption
Use Oracle Key Vault to
encrypt your data at rest.
3
It is a package of utilities that are used for maintenance and
administration of MySQL servers. These utilities encapsulate
a set of primitive commands, and bundles them so they can
be used to perform macro operations with a single
command.
The utilities are written in Python, available under the GPLv2
license, and are extendable using the supplied library. They
are designed to work with Python versions 2.6 or later and
there is no support (yet) for Python v3.1.
The MySQL Utilities?
FREE! FREE! 4
The MySQL
Utilities are
scripts
Designed to be easily
extensible, use common
interfaces, and designed to
make complex operations
simple
In other words they automate some
fairly gruesome tasks to save you
time and sanity
5
https://dev.mysql.com/downloads/utilities/
It is a separate download from MySQL Server
Included with MySQL Workbench
Where to get the
MySQL Utilities?
6
Why Use Them?
7
Compare and Contrast -- Copy a database
8
1. On server 1
a. mysqldump -u root World City > foo.sql
b. Scp foo.sql server2
2. On server 2
a. Mysql -u root World < foo.sql
1. On server1 OR server2 or ??
a. Mysqldbcopy --source=root@server1 
-destination=root@server2 
world:world
Six Area of Use
Binary Log Operations
Database Operations
General Operations
High Availability Operations
Server Operations
Specialized Operations
9
10
mysqlauditadmin — Allows users to perform maintenance actions on the audit log
mysqlauditgrep — Allows users to search the current or an archived audit log
mysqlbinlogmove — Binary log relocate utility
mysqlbinlogpurge — Binary log purge utility
mysqlbinlogrotate — Binary log rotate utility
mysqldbcompare — Compare Two Databases and Identify Differences
mysqldbcopy — Copy Database Objects Between Servers
mysqldbexport — Export Object Definitions or Data from a Database
mysqldbimport — Import Object Definitions or Data into a Database
mysqldiff — Identify Differences Among Database Objects
mysqldiskusage — Show Database Disk Usage
mysqlfailover — Automatic replication health monitoring and failover
mysqlfrm — File reader for .frm files.
mysqlgrants — Display grants by object
mysqlindexcheck — Identify Potentially Redundant Table Indexes
mysqlmetagrep — Search Database Object Definitions
mysqlprocgrep — Search Server Process Lists
mysqlreplicate — Set Up and Start Replication Between Two Servers
mysqlrplms — Set Up and Start Replication from a Slave to Multiple Masters
mysqlrpladmin — Administration utility for MySQL replication
mysqlrplcheck — Check Replication Prerequisites
mysqlrplshow — Show Slaves for Master Server
mysqlrplsync — Replication synchronization checker
mysqlserverclone — Clone Existing Server to Create New Server
mysqlserverinfo — Display Common Diagnostic Information from a Server
mysqlslavetrx — Slave transaction skip utility
mysqluc — Command line client for running MySQL Utilities
mysqluserclone — Clone Existing User to Create New User
Examples
There are 28
MySQL Utilities
and rather than go into
detail on all of them, let us
peek at some common
tasks using the MySQL
Utilities to show you how
you can use them
11
Example 1
Setup automatic failover on four
MySQL instances running on
one server
Master server is
on port 3331 and
there other
servers are setup
on 3332, 3333,
and 3334
12
shell> mysqlfailover --master=root@localhost:3331 --discover-
slaves-login=root --log=log.txt
MySQL Replication Monitor and Failover Utility
Failover Mode = auto Next Interval = Mon Mar 19 15:56:03 2012
Master Information
------------------
Binary Log File Position Binlog_Do_DB Binlog_Ignore_DB
mysql-bin.000001 571
GTID Executed Set
2A67DE00-2DA1-11E2-A711-00764F2BE90F:1-7 [...]
Replication Health Status
+------------+-------+---------+--------+------------+---------+
| host | port | role | state | gtid_mode | health |
+------------+-------+---------+--------+------------+---------+
| localhost | 3331 | MASTER | UP | ON | OK |
| localhost | 3332 | SLAVE | UP | ON | OK |
| localhost | 3333 | SLAVE | UP | ON | OK |
| localhost | 3334 | SLAVE | UP | ON | OK |
+------------+-------+---------+--------+------------+---------+
Q-quit R-refresh H-health G-GTID Lists U-UUIDs L-log entries
13
Q-quit R-refresh H-health G-GTID Lists U-UUIDs L-log entries
If we press G -- GTID Report
Master Information
------------------
Binary Log File Position Binlog_Do_DB Binlog_Ignore_DB
mysql-bin.000001 571
GTID Executed Set
2A67DE00-2DA1-11E2-A711-00764F2BE90F:1-7 [...]
Master GTID Executed Set
+-------------------------------------------+
| gtid |
+-------------------------------------------+
| 2A67DE00-2DA1-11E2-A711-00764F2BE90F:1-7 |
| 5503D37E-2DB2-11E2-A781-8077D4C14B33:1-3 |
+-------------------------------------------+
14
Failover?
Failover starting...
# Candidate slave localhost:3332 will become the new master.
# Preparing candidate for failover.
# Creating replication user if it does not exist.
# Stopping slaves.
# Performing STOP on all slaves.
# Switching slaves to new master.
# Starting slaves.
# Performing START on all slaves.
# Checking slaves for errors.
# Failover complete.
# Discovering slaves for master at localhost:3332
Failover console will restart in 5 seconds.
15
Failed over!!
MySQL Replication Monitor and Failover Utility
Failover Mode = auto Next Interval = Mon Mar 19 16:05:12 2012
Master Information
------------------
Binary Log File Position Binlog_Do_DB Binlog_Ignore_DB
mysql-bin.000001 1117
GTID Executed Set
2A67DE00-2DA1-11E2-A711-00764F2BE90F:1-7 [...]
UUIDs
+------------+-------+---------+--------+------------+---------+
| host | port | role | state | gtid_mode | health |
+------------+-------+---------+--------+------------+---------+
| localhost | 3332 | MASTER | UP | ON | OK |
| localhost | 3333 | SLAVE | UP | ON | OK |
| localhost | 3334 | SLAVE | UP | ON | OK |
+------------+-------+---------+--------+------------+---------+
16
Compare Two
Databases and
Identify
Differences
This utility compares the objects
and data from two databases to find
differences. It identifies objects
having different definitions in the
two databases and presents them
in a diff-style format of choice.
Differences in the data are shown
using a similar diff-style format.
Changed or missing rows are
shown in a standard format of
GRID, CSV, TAB, or VERTICAL.
‘But it works in test!!’
17
mysqldbcompare --server1=root@localhost emp1:emp2 --run-
all-tests
# server1 on localhost: ... connected.
# Checking databases emp1 on server1 and emp2 on server2
#
# WARNING: Objects in server2:emp2 but not in server1:emp1:
# TRIGGER: trg
# PROCEDURE: p1
# TABLE: t1
# VIEW: v1
#
18
mysqldbcompare --server1=root@localhost emp1:emp2 --run-
all-tests continued
# Data differences found among rows:
--- emp1.departments
+++ emp2.departments
@@ -1,4 +1,4 @@
************************* 1. row *************************
dept_no: d002
- dept_name: dunno
+ dept_name: Finance
1 rows.
19
mysqldbcompare --server1=root@localhost emp1:emp2 --run-
all-tests continued even more!
# Rows in emp1.departments not in emp2.departments
************************* 1. row *************************
dept_no: d008
dept_name: Research
1 rows.
# Rows in emp2.departments not in emp1.departments
************************* 1. row *************************
dept_no: d100
dept_name: stupid
1 rows.
20
mysqldbcompare --server1=root@localhost emp1:emp2 --run-
all-tests continued even more again!!
# TABLE dept_manager pass pass -
# - Compare table checksum pass
# Database consistency check failed.
#
# ...done
21
Disk Usage
shell> mysqldiskusage --server=root@localhost employees test
# Source on localhost: ... connected.
# Database totals:
+------------+--------------+
| db_name | total |
+------------+--------------+
| employees | 205,979,648 |
| test | 4,096 |
+------------+--------------+
Total database disk usage = 205,983,744 bytes or 196.00 MB
#...done. 22
shell> mysqldiskusage --server=root@localhost --format=csv -a -vv
# Source on localhost: ... connected.
# Database totals:
db_name,db_dir_size,data_size,misc_files,total
test1,0,0,0,0
db3,0,0,0,0
db2,0,0,0,0
db1,0,0,0,0
backup_test,19410,1117,18293,19410
employees,242519463,205979648,242519463,448499111
mysql,867211,657669,191720,849389
t1,9849,1024,8825,9849
test,56162,4096,52066,56162
util_test_a,19625,2048,17577,19625
util_test_b,17347,0,17347,17347
util_test_c,19623,2048,17575,19623
23
mysqlindexcheck — Identify Potentially Redundant Table Indexes
shell> mysqlindexcheck --server=root@localhost employees
# Source on localhost: ... connected.
# The following indexes are duplicates or redundant 
for table employees.dept_emp:
#
CREATE INDEX emp_no ON employees.dept_emp (emp_no) USING BTREE
# may be redundant or duplicate of:
ALTER TABLE employees.dept_emp ADD PRIMARY KEY (emp_no, dept_no)
# The following indexes are duplicates or redundant 
for table employees.dept_manager:
#
CREATE INDEX emp_no ON employees.dept_manager (emp_no) USING BTREE
# may be redundant or duplicate of:
ALTER TABLE employees.dept_manager ADD PRIMARY KEY (emp_no, dept_no)
# The following indexes are duplicates or redundant 
for table employees.salaries:
# 24
25
shell> mysqluserclone --source=root@localhost 
--destination=root@localhost 
joe@localhost sam:secret1@localhost
sally:secret2@localhost
# Source on localhost: ... connected.
# Destination on localhost: ... connected.
# Cloning 2 users...
# Cloning joe@localhost to user sam:secret1@localhost
# Cloning joe@localhost to user sally:secret2@localhost
# ...done.
Note: SYS Schema (MySQL 5.6/7) allows you to
find redundant indexes, queries running
without indexes, and help your spot queries
that may need indexes.
26
Check Grants -- who has permission to do what
shell> mysqlgrants --server=user:pass@localhost:3310 
--show=user_grants util_test util_test.t3 util_test.t2 
util_test.t1 util_test.p1 util_test.f1
# DATABASE `util_test`:
# - 'joe'@'user' : ALL PRIVILEGES
# - 'joe_wildcard'@'%' : ALL PRIVILEGES
# - 'priv_test_user'@'%' : EXECUTE, GRANT OPTION, SELECT, TRIGGER, UPDATE
# - 'priv_test_user2'@'%' : EXECUTE, SELECT, UPDATE
# - 'priv_test_user3'@'%' : ALTER ROUTINE, DELETE, DROP, EXECUTE, TRIGGER,
UPDATE
# TABLE `util_test`.`t1`:
# - 'joe'@'user' : ALL PRIVILEGES
# - 'joe_wildcard'@'%' : ALL PRIVILEGES
# - 'priv_test_user'@'%' : GRANT OPTION, SELECT, TRIGGER, UPDATE
# - 'priv_test_user2'@'%' : ALL PRIVILEGES, GRANT OPTION
# - 'priv_test_user3'@'%' : DELETE, DROP, TRIGGER, UPDATE
shell> mysqlgrants --server=user:pass@localhost:3310 
--show=raw util_test util_test.t3 util_test.t2 
util_test.t1 util_test.p1 util_test.f1
# DATABASE `util_test`:
# - For 'joe'@'user'
GRANT ALL PRIVILEGES ON `util_test`.* TO 'joe'@'user'
# - For 'joe_wildcard'@'%'
GRANT ALL PRIVILEGES ON `util_test`.* TO 'joe_wildcard'@'%'
# - For 'priv_test_user'@'%'
GRANT EXECUTE, TRIGGER ON `util_test`.* TO 'priv_test_user'@'%' WITH GRANT
OPTION
GRANT SELECT, UPDATE ON *.* TO 'priv_test_user'@'%'
# - For 'priv_test_user2'@'%'
GRANT SELECT, UPDATE, SHUTDOWN, EXECUTE ON *.* TO 'priv_test_user2'@'%'
# - For 'priv_test_user3'@'%'
GRANT DROP, EXECUTE, TRIGGER ON *.* TO 'priv_test_user3'@'%'
GRANT UPDATE, DELETE, ALTER ROUTINE ON `util_test`.* TO 'priv_test_user3'@'%'
27
Find all objects with a name that matches the pattern 't_' (the
letter t followed by any single character)
28
shell> mysqlmetagrep --pattern="t_" --server=john@localhost
+------------------------+--------------+--------------+-----------+
| Connection | Object Type | Object Name | Database |
+------------------------+--------------+--------------+-----------+
| john:*@localhost:3306 | TABLE | t1 | test |
| john:*@localhost:3306 | TABLE | t2 | test |
| john:*@localhost:3306 | TABLE | tm | test |
+------------------------+--------------+--------------+-----------+
shell> mysqlmetagrep -b --pattern="%t2%" --
server=john@localhost:3306
+------------------------+--------------+--------------+-----------+
| Connection | Object Type | Object Name | Database |
+------------------------+--------------+--------------+-----------+
| john:*@localhost:3306 | TRIGGER | tr_foo | test |
| john:*@localhost:3306 | TABLE | t2 | test |
+------------------------+--------------+--------------+-----------+
29
QUESTION: Why is tr_foo listed here when the Object Name does
not match “%t2%”?????
Answer: the TRIGGER tr_foo’s body references the object ‘t2’
Process control
shell> mysqlprocgrep --server=root@localhost 
--match-command=sleep --age=1h --kill-connection
You can remove MySQL queries that have been
sleeping for one hour
30
mysqluc
31
...is part of MySQL Workbench (found
under tools) and it gives you access to
the MySQL Utilities
And you can skip the first 5 letters of
each command
Mysqldbcopy = dbcopy
Find process
mysqluc> procgrep --sql --match-user=root --match-state=starting --print
SELECT
Id, User, Host, Db, Command, Time, State, Info
FROM
INFORMATION_SCHEMA.PROCESSLIST
WHERE
USER LIKE 'root'
AND
STATE LIKE 'starting'
32
shell> mysqlprocgrep --kill-connection --sql-body 
--match-user=www-data --match-state=sleep
DECLARE kill_done INT;
DECLARE kill_cursor CURSOR FOR
SELECT
Id, User, Host, Db, Command, Time, State, Info
FROM
INFORMATION_SCHEMA.PROCESSLIST
WHERE
user LIKE 'www-data'
AND
State LIKE 'sleep'
OPEN kill_cursor;
BEGIN
DECLARE id BIGINT;
DECLARE EXIT HANDLER FOR NOT FOUND SET kill_done = 1;
kill_loop: LOOP
FETCH kill_cursor INTO id;
KILL CONNECTION id;
END LOOP kill_loop;
END;
CLOSE kill_cursor;
33
Replication made easy - Are the settings good
shell> mysqlrplcheck --master=root@host1:3310 --
slave=root@host2:3311
# master on host1: ... connected.
# slave on host2: ... connected.
Test Description Status
------------------------------------------------------------------------
Checking for binary logging on master [pass]
Are there binlog exceptions? [pass]
Replication user exists? [pass]
Checking server_id values [pass]
Is slave connected to master? [pass]
Check master information file [pass]
Checking InnoDB compatibility [pass]
Checking storage engines compatibility [pass]
Checking lower_case_table_names settings [pass]
Checking slave delay (seconds behind master) [pass]
34
See the topology
shell> mysqlrplshow --master=root@localhost:3311 --recurse --
discover-slaves-ln=rootogi
# master on localhost: ... connected.
# Finding slaves for master: localhost:3311
# Replication Topology Graph
localhost:3311 (MASTER)
|
+--- localhost:3310 - (SLAVE)
|
+--- localhost:3312 - (SLAVE + MASTER)
|
+--- localhost:3313 - (SLAVE)
35
Cloneshell> mkdir /source/test123
shell> mysqlserverclone --server=root:pass@localhost 
--new-data=/Users/cbell/source/test123 --new-port=3310 
--root-password=pass --mysqld=--log-bin=mysql-bin
# Cloning the MySQL server running on localhost.
# Creating new data directory...
# Configuring new instance...
# Locating mysql tools...
# Setting up empty database and mysql tables...
# Starting new instance of the server...
# Testing connection to new instance...
# Success!
# Setting the root password...
# ...done.
36
37
shell> mysqlrplms --slave=root:root@localhost:3306 
--masters=root:root@localhost:3307,root:root@localhost:3308
# Starting multi-source replication...
# Press CTRL+C to quit.
# Switching to master 'localhost:3307'.
# master on localhost: ... connected.
# slave on localhost: ... connected.
#
# Current Master Information:
+-------------------+-----------+---------------+-------------------+
| Binary Log File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-------------------+-----------+---------------+-------------------+
| clone-bin.000001 | 594 | N/A | N/A |
+-------------------+-----------+---------------+-------------------+
# GTID Executed Set: 00a4e027-a83a-11e3-8bd6-28d244017f26:1-2
#
# Health Status:
+------------+-------+---------+--------+------------+---------+
| host | port | role | state | gtid_mode | health |
+------------+-------+---------+--------+------------+---------+
| localhost | 3307 | MASTER | UP | ON | OK |
| localhost | 3306 | SLAVE | UP | ON | OK |
| localhost | 3308 | MASTER | UP | ON | OK |
+------------+-------+---------+--------+------------+---------+
38
shell> mysqlrpladmin --master=root@localhost:3331 
--slaves=root@localhost:3332,root@localhost:3333,root@localhost:3334 
--candidates=root@localhost:3333,root@localhost:3334 elect
# Electing candidate slave from candidate list then slaves list.
# Best slave found is located on localhost:3332.
# ...done.
List Candidate Slaves
Skips a GTID Transaction
shell> mysqlslavetrx --gtid-set=af6b22ee-7b0b-11e4-aa8d-
606720440b68:7-9 
--
slaves=user:pass@localhost:3311,user:pass@localhost:3312
WARNING: Using a password on the command line interface can
be insecure.
#
# GTID set to be skipped for each server:
# - localhost@3311: af6b22ee-7b0b-11e4-aa8d-606720440b68:7-9
# - localhost@3312: af6b22ee-7b0b-11e4-aa8d-606720440b68:7-9
#
# Injecting empty transactions for 'localhost:3311'...
# Injecting empty transactions for 'localhost:3312'...
#
#...done.
39
Extending
Easy to extend with a very nice example in the docs. All utils use a three tier
organization and support on the Utilities section of Forums.MySQL.Com
http://forums.mysql.com/list.php?144
How to at:
https://dev.mysql.com/doc/mysql-utilities/1.6/en/mysql-utils-intro-developers.html
40
Other Recommended Tools
MySQL Workbench
https://dev.mysql.com/downloads/workbench/
Percona Toolkit
https://www.percona.com/software/database-tools/percona-toolkit
41
Dave Stokes - MySQL Community Manager
David.Stokes@Oracle.Com
@Stoker
slideshare.net/davidmstokes
Elephantanddolphin.blogger.com or opensourcedba.wordpress.com
42

Contenu connexe

Tendances

Discard inport exchange table & tablespace
Discard inport exchange table & tablespaceDiscard inport exchange table & tablespace
Discard inport exchange table & tablespace
Marco Tusa
 

Tendances (20)

Open Source World June '21 -- JSON Within a Relational Database
Open Source World June '21 -- JSON Within a Relational DatabaseOpen Source World June '21 -- JSON Within a Relational Database
Open Source World June '21 -- JSON Within a Relational Database
 
Oss4b - pxc introduction
Oss4b   - pxc introductionOss4b   - pxc introduction
Oss4b - pxc introduction
 
MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바
 
OTN Tour 2014: Rac 11g vs 12c
OTN Tour 2014: Rac 11g vs 12cOTN Tour 2014: Rac 11g vs 12c
OTN Tour 2014: Rac 11g vs 12c
 
MySQL Cluster Performance Tuning - 2013 MySQL User Conference
MySQL Cluster Performance Tuning - 2013 MySQL User ConferenceMySQL Cluster Performance Tuning - 2013 MySQL User Conference
MySQL Cluster Performance Tuning - 2013 MySQL User Conference
 
Midwest PHP Presentation - New MSQL Features
Midwest PHP Presentation - New MSQL FeaturesMidwest PHP Presentation - New MSQL Features
Midwest PHP Presentation - New MSQL Features
 
Discard inport exchange table & tablespace
Discard inport exchange table & tablespaceDiscard inport exchange table & tablespace
Discard inport exchange table & tablespace
 
Galera Replication Demystified: How Does It Work?
Galera Replication Demystified: How Does It Work?Galera Replication Demystified: How Does It Work?
Galera Replication Demystified: How Does It Work?
 
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group ReplicationPercona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
 
MySQL 5.6 config 優化
MySQL 5.6 config 優化MySQL 5.6 config 優化
MySQL 5.6 config 優化
 
MySQL Replication Update - DEbconf 2020 presentation
MySQL Replication Update - DEbconf 2020 presentationMySQL Replication Update - DEbconf 2020 presentation
MySQL Replication Update - DEbconf 2020 presentation
 
Galera explained 3
Galera explained 3Galera explained 3
Galera explained 3
 
MySQL 8.0 Operational Changes
MySQL 8.0 Operational ChangesMySQL 8.0 Operational Changes
MySQL 8.0 Operational Changes
 
MySQL For Oracle DBA's and Developers
MySQL For Oracle DBA's and DevelopersMySQL For Oracle DBA's and Developers
MySQL For Oracle DBA's and Developers
 
PNWPHP -- What are Databases so &#%-ing Difficult
PNWPHP -- What are Databases so &#%-ing DifficultPNWPHP -- What are Databases so &#%-ing Difficult
PNWPHP -- What are Databases so &#%-ing Difficult
 
MySQL's NoSQL -- Texas Linuxfest August 22nd 2015
MySQL's NoSQL  -- Texas Linuxfest August 22nd 2015MySQL's NoSQL  -- Texas Linuxfest August 22nd 2015
MySQL's NoSQL -- Texas Linuxfest August 22nd 2015
 
Galera Cluster: Synchronous Multi-Master Replication for MySQL HA
Galera Cluster: Synchronous Multi-Master Replication for MySQL HAGalera Cluster: Synchronous Multi-Master Replication for MySQL HA
Galera Cluster: Synchronous Multi-Master Replication for MySQL HA
 
Multi thread slave_performance_on_opc
Multi thread slave_performance_on_opcMulti thread slave_performance_on_opc
Multi thread slave_performance_on_opc
 
MySQL High Availability Solutions - Avoid loss of service by reducing the r...
MySQL High Availability Solutions  -  Avoid loss of service by reducing the r...MySQL High Availability Solutions  -  Avoid loss of service by reducing the r...
MySQL High Availability Solutions - Avoid loss of service by reducing the r...
 
Datacon LA - MySQL without the SQL - Oh my!
Datacon LA - MySQL without the SQL - Oh my! Datacon LA - MySQL without the SQL - Oh my!
Datacon LA - MySQL without the SQL - Oh my!
 

En vedette

Hp Polyserve Database Utility For Sql Server Consolidation
Hp Polyserve Database Utility For Sql Server ConsolidationHp Polyserve Database Utility For Sql Server Consolidation
Hp Polyserve Database Utility For Sql Server Consolidation
CB UTBlog
 
How to analyze and tune sql queries for better performance webinar
How to analyze and tune sql queries for better performance webinarHow to analyze and tune sql queries for better performance webinar
How to analyze and tune sql queries for better performance webinar
oysteing
 
MySQL Query And Index Tuning
MySQL Query And Index TuningMySQL Query And Index Tuning
MySQL Query And Index Tuning
Manikanda kumar
 

En vedette (20)

Database system utilities by dinesh
Database system utilities by dineshDatabase system utilities by dinesh
Database system utilities by dinesh
 
Ra framework 0.1
Ra framework 0.1Ra framework 0.1
Ra framework 0.1
 
Tera data install guide for linux
Tera data install guide for linuxTera data install guide for linux
Tera data install guide for linux
 
Database Tools - ER Studio Facts and Features
Database Tools - ER Studio Facts and FeaturesDatabase Tools - ER Studio Facts and Features
Database Tools - ER Studio Facts and Features
 
Hp Polyserve Database Utility For Sql Server Consolidation
Hp Polyserve Database Utility For Sql Server ConsolidationHp Polyserve Database Utility For Sql Server Consolidation
Hp Polyserve Database Utility For Sql Server Consolidation
 
Literature Survey on Mobile Database Tools
Literature Survey on Mobile Database ToolsLiterature Survey on Mobile Database Tools
Literature Survey on Mobile Database Tools
 
Five Database Mistakes and how to fix them -- Confoo Vancouver
Five Database Mistakes and how to fix them -- Confoo VancouverFive Database Mistakes and how to fix them -- Confoo Vancouver
Five Database Mistakes and how to fix them -- Confoo Vancouver
 
Scaling MySQL -- Swanseacon.co.uk
Scaling MySQL -- Swanseacon.co.uk Scaling MySQL -- Swanseacon.co.uk
Scaling MySQL -- Swanseacon.co.uk
 
Polyglot Database - Linuxcon North America 2016
Polyglot Database - Linuxcon North America 2016Polyglot Database - Linuxcon North America 2016
Polyglot Database - Linuxcon North America 2016
 
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
 
How to analyze and tune sql queries for better performance percona15
How to analyze and tune sql queries for better performance percona15How to analyze and tune sql queries for better performance percona15
How to analyze and tune sql queries for better performance percona15
 
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
 
MySQL EXPLAIN Explained-Norvald H. Ryeng
MySQL EXPLAIN Explained-Norvald H. RyengMySQL EXPLAIN Explained-Norvald H. Ryeng
MySQL EXPLAIN Explained-Norvald H. Ryeng
 
What Your Database Query is Really Doing
What Your Database Query is Really DoingWhat Your Database Query is Really Doing
What Your Database Query is Really Doing
 
How to analyze and tune sql queries for better performance vts2016
How to analyze and tune sql queries for better performance vts2016How to analyze and tune sql queries for better performance vts2016
How to analyze and tune sql queries for better performance vts2016
 
MySQL 8.0: GIS — Are you ready?
MySQL 8.0: GIS — Are you ready?MySQL 8.0: GIS — Are you ready?
MySQL 8.0: GIS — Are you ready?
 
MySQL Performance Tips & Best Practices
MySQL Performance Tips & Best PracticesMySQL Performance Tips & Best Practices
MySQL Performance Tips & Best Practices
 
How to analyze and tune sql queries for better performance webinar
How to analyze and tune sql queries for better performance webinarHow to analyze and tune sql queries for better performance webinar
How to analyze and tune sql queries for better performance webinar
 
SQL window functions for MySQL
SQL window functions for MySQLSQL window functions for MySQL
SQL window functions for MySQL
 
MySQL Query And Index Tuning
MySQL Query And Index TuningMySQL Query And Index Tuning
MySQL Query And Index Tuning
 

Similaire à MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016

Whitepaper MS SQL Server on Linux
Whitepaper MS SQL Server on LinuxWhitepaper MS SQL Server on Linux
Whitepaper MS SQL Server on Linux
Roger Eisentrager
 
Replication features, technologies and 3rd party Extinction
Replication features, technologies and 3rd party ExtinctionReplication features, technologies and 3rd party Extinction
Replication features, technologies and 3rd party Extinction
Ben Mildren
 

Similaire à MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016 (20)

MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017
 
ConFoo MySQL Replication Evolution : From Simple to Group Replication
ConFoo  MySQL Replication Evolution : From Simple to Group ReplicationConFoo  MySQL Replication Evolution : From Simple to Group Replication
ConFoo MySQL Replication Evolution : From Simple to Group Replication
 
MySQL Replication Overview -- PHPTek 2016
MySQL Replication Overview -- PHPTek 2016MySQL Replication Overview -- PHPTek 2016
MySQL Replication Overview -- PHPTek 2016
 
Multiple instances on linux
Multiple instances on linuxMultiple instances on linux
Multiple instances on linux
 
MySQL 101 PHPTek 2017
MySQL 101 PHPTek 2017MySQL 101 PHPTek 2017
MySQL 101 PHPTek 2017
 
Whitepaper MS SQL Server on Linux
Whitepaper MS SQL Server on LinuxWhitepaper MS SQL Server on Linux
Whitepaper MS SQL Server on Linux
 
MySQL Cluster 7.3 Performance Tuning - Severalnines Slides
MySQL Cluster 7.3 Performance Tuning - Severalnines SlidesMySQL Cluster 7.3 Performance Tuning - Severalnines Slides
MySQL Cluster 7.3 Performance Tuning - Severalnines Slides
 
MySQL for Large Scale Social Games
MySQL for Large Scale Social GamesMySQL for Large Scale Social Games
MySQL for Large Scale Social Games
 
MySQL User Group NL - MySQL 8
MySQL User Group NL - MySQL 8MySQL User Group NL - MySQL 8
MySQL User Group NL - MySQL 8
 
Percona Live '18 Tutorial: The Accidental DBA
Percona Live '18 Tutorial: The Accidental DBAPercona Live '18 Tutorial: The Accidental DBA
Percona Live '18 Tutorial: The Accidental DBA
 
Mysql
Mysql Mysql
Mysql
 
Migrate database to Exadata using RMAN duplicate
Migrate database to Exadata using RMAN duplicateMigrate database to Exadata using RMAN duplicate
Migrate database to Exadata using RMAN duplicate
 
Replication features, technologies and 3rd party Extinction
Replication features, technologies and 3rd party ExtinctionReplication features, technologies and 3rd party Extinction
Replication features, technologies and 3rd party Extinction
 
Easy MySQL Replication Setup and Troubleshooting
Easy MySQL Replication Setup and TroubleshootingEasy MySQL Replication Setup and Troubleshooting
Easy MySQL Replication Setup and Troubleshooting
 
Mysql replication @ gnugroup
Mysql replication @ gnugroupMysql replication @ gnugroup
Mysql replication @ gnugroup
 
Enterprise manager cloud control 12c(12.1) &agent安装图文指南
Enterprise manager cloud control 12c(12.1) &agent安装图文指南Enterprise manager cloud control 12c(12.1) &agent安装图文指南
Enterprise manager cloud control 12c(12.1) &agent安装图文指南
 
Exploring mysql cluster 7.4
Exploring mysql cluster 7.4Exploring mysql cluster 7.4
Exploring mysql cluster 7.4
 
MySQL for Oracle DBAs
MySQL for Oracle DBAsMySQL for Oracle DBAs
MySQL for Oracle DBAs
 
OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert VanderkelenOSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
 
Asian Spirit 3 Day Dba On Ubl
Asian Spirit 3 Day Dba On UblAsian Spirit 3 Day Dba On Ubl
Asian Spirit 3 Day Dba On Ubl
 

Plus de Dave Stokes

Plus de Dave Stokes (20)

Locking Down Your MySQL Database.pptx
Locking Down Your MySQL Database.pptxLocking Down Your MySQL Database.pptx
Locking Down Your MySQL Database.pptx
 
Linuxfest Northwest 2022 - MySQL 8.0 Nre Features
Linuxfest Northwest 2022 - MySQL 8.0 Nre FeaturesLinuxfest Northwest 2022 - MySQL 8.0 Nre Features
Linuxfest Northwest 2022 - MySQL 8.0 Nre Features
 
MySQL Indexes and Histograms - RMOUG Training Days 2022
MySQL Indexes and Histograms - RMOUG Training Days 2022MySQL Indexes and Histograms - RMOUG Training Days 2022
MySQL Indexes and Histograms - RMOUG Training Days 2022
 
MySQL 8.0 Features -- Oracle CodeOne 2019, All Things Open 2019
MySQL 8.0 Features -- Oracle CodeOne 2019, All Things Open 2019MySQL 8.0 Features -- Oracle CodeOne 2019, All Things Open 2019
MySQL 8.0 Features -- Oracle CodeOne 2019, All Things Open 2019
 
Windowing Functions - Little Rock Tech fest 2019
Windowing Functions - Little Rock Tech fest 2019Windowing Functions - Little Rock Tech fest 2019
Windowing Functions - Little Rock Tech fest 2019
 
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
 
Develop PHP Applications with MySQL X DevAPI
Develop PHP Applications with MySQL X DevAPIDevelop PHP Applications with MySQL X DevAPI
Develop PHP Applications with MySQL X DevAPI
 
MySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
MySQL 8 Tips and Tricks from Symfony USA 2018, San FranciscoMySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
MySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
 
The Proper Care and Feeding of MySQL Databases
The Proper Care and Feeding of MySQL DatabasesThe Proper Care and Feeding of MySQL Databases
The Proper Care and Feeding of MySQL Databases
 
MySQL without the SQL -- Cascadia PHP
MySQL without the SQL -- Cascadia PHPMySQL without the SQL -- Cascadia PHP
MySQL without the SQL -- Cascadia PHP
 
MySQL 8 Server Optimization Swanseacon 2018
MySQL 8 Server Optimization Swanseacon 2018MySQL 8 Server Optimization Swanseacon 2018
MySQL 8 Server Optimization Swanseacon 2018
 
MySQL Without The SQL -- Oh My! PHP[Tek] June 2018
MySQL Without The SQL -- Oh My! PHP[Tek] June 2018MySQL Without The SQL -- Oh My! PHP[Tek] June 2018
MySQL Without The SQL -- Oh My! PHP[Tek] June 2018
 
Presentation Skills for Open Source Folks
Presentation Skills for Open Source FolksPresentation Skills for Open Source Folks
Presentation Skills for Open Source Folks
 
MySQL Without the SQL -- Oh My! Longhorn PHP Conference
MySQL Without the SQL -- Oh My!  Longhorn PHP ConferenceMySQL Without the SQL -- Oh My!  Longhorn PHP Conference
MySQL Without the SQL -- Oh My! Longhorn PHP Conference
 
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
 
Advanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsAdvanced MySQL Query Optimizations
Advanced MySQL Query Optimizations
 
Making MySQL Agile-ish
Making MySQL Agile-ishMaking MySQL Agile-ish
Making MySQL Agile-ish
 
PHP Database Programming Basics -- Northeast PHP
PHP Database Programming Basics -- Northeast PHPPHP Database Programming Basics -- Northeast PHP
PHP Database Programming Basics -- Northeast PHP
 
MySQL's JSON Data Type and Document Store
MySQL's JSON Data Type and Document StoreMySQL's JSON Data Type and Document Store
MySQL's JSON Data Type and Document Store
 
Why Your Database Queries Stink -SeaGl.org November 11th, 2016
Why Your Database Queries Stink -SeaGl.org November 11th, 2016Why Your Database Queries Stink -SeaGl.org November 11th, 2016
Why Your Database Queries Stink -SeaGl.org November 11th, 2016
 

Dernier

一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
ayvbos
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
ayvbos
 
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
ydyuyu
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
gajnagarg
 
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Monica Sydney
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
JOHNBEBONYAP1
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
ydyuyu
 
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
pxcywzqs
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
ydyuyu
 

Dernier (20)

2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
 
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
 
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
 
Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.
 
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
 
Best SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasBest SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency Dallas
 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
 

MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016

  • 2. Dave Stokes - MySQL Community Manager David.Stokes@Oracle.Com @Stoker slideshare.net/davidmstokes Elephantanddolphin.blogger.com or opensourcedba.wordpress.com 2
  • 3. 21 Years Old MySQL has been part of Oracle’s family of databases for six years. MySQL 8 MySQl 5.7 is the current release but the next version will be MySQL 8. Big feature is real time data dictionary Group Replication Active master-master replication. JSON A new native JSON datatype to store documents in a column of a table Document Store Programmers not know SQL but need a database? X Devapi allows them to use RDMS from language of choice Encryption Use Oracle Key Vault to encrypt your data at rest. 3
  • 4. It is a package of utilities that are used for maintenance and administration of MySQL servers. These utilities encapsulate a set of primitive commands, and bundles them so they can be used to perform macro operations with a single command. The utilities are written in Python, available under the GPLv2 license, and are extendable using the supplied library. They are designed to work with Python versions 2.6 or later and there is no support (yet) for Python v3.1. The MySQL Utilities? FREE! FREE! 4
  • 5. The MySQL Utilities are scripts Designed to be easily extensible, use common interfaces, and designed to make complex operations simple In other words they automate some fairly gruesome tasks to save you time and sanity 5
  • 6. https://dev.mysql.com/downloads/utilities/ It is a separate download from MySQL Server Included with MySQL Workbench Where to get the MySQL Utilities? 6
  • 8. Compare and Contrast -- Copy a database 8 1. On server 1 a. mysqldump -u root World City > foo.sql b. Scp foo.sql server2 2. On server 2 a. Mysql -u root World < foo.sql 1. On server1 OR server2 or ?? a. Mysqldbcopy --source=root@server1 -destination=root@server2 world:world
  • 9. Six Area of Use Binary Log Operations Database Operations General Operations High Availability Operations Server Operations Specialized Operations 9
  • 10. 10 mysqlauditadmin — Allows users to perform maintenance actions on the audit log mysqlauditgrep — Allows users to search the current or an archived audit log mysqlbinlogmove — Binary log relocate utility mysqlbinlogpurge — Binary log purge utility mysqlbinlogrotate — Binary log rotate utility mysqldbcompare — Compare Two Databases and Identify Differences mysqldbcopy — Copy Database Objects Between Servers mysqldbexport — Export Object Definitions or Data from a Database mysqldbimport — Import Object Definitions or Data into a Database mysqldiff — Identify Differences Among Database Objects mysqldiskusage — Show Database Disk Usage mysqlfailover — Automatic replication health monitoring and failover mysqlfrm — File reader for .frm files. mysqlgrants — Display grants by object mysqlindexcheck — Identify Potentially Redundant Table Indexes mysqlmetagrep — Search Database Object Definitions mysqlprocgrep — Search Server Process Lists mysqlreplicate — Set Up and Start Replication Between Two Servers mysqlrplms — Set Up and Start Replication from a Slave to Multiple Masters mysqlrpladmin — Administration utility for MySQL replication mysqlrplcheck — Check Replication Prerequisites mysqlrplshow — Show Slaves for Master Server mysqlrplsync — Replication synchronization checker mysqlserverclone — Clone Existing Server to Create New Server mysqlserverinfo — Display Common Diagnostic Information from a Server mysqlslavetrx — Slave transaction skip utility mysqluc — Command line client for running MySQL Utilities mysqluserclone — Clone Existing User to Create New User
  • 11. Examples There are 28 MySQL Utilities and rather than go into detail on all of them, let us peek at some common tasks using the MySQL Utilities to show you how you can use them 11
  • 12. Example 1 Setup automatic failover on four MySQL instances running on one server Master server is on port 3331 and there other servers are setup on 3332, 3333, and 3334 12
  • 13. shell> mysqlfailover --master=root@localhost:3331 --discover- slaves-login=root --log=log.txt MySQL Replication Monitor and Failover Utility Failover Mode = auto Next Interval = Mon Mar 19 15:56:03 2012 Master Information ------------------ Binary Log File Position Binlog_Do_DB Binlog_Ignore_DB mysql-bin.000001 571 GTID Executed Set 2A67DE00-2DA1-11E2-A711-00764F2BE90F:1-7 [...] Replication Health Status +------------+-------+---------+--------+------------+---------+ | host | port | role | state | gtid_mode | health | +------------+-------+---------+--------+------------+---------+ | localhost | 3331 | MASTER | UP | ON | OK | | localhost | 3332 | SLAVE | UP | ON | OK | | localhost | 3333 | SLAVE | UP | ON | OK | | localhost | 3334 | SLAVE | UP | ON | OK | +------------+-------+---------+--------+------------+---------+ Q-quit R-refresh H-health G-GTID Lists U-UUIDs L-log entries 13
  • 14. Q-quit R-refresh H-health G-GTID Lists U-UUIDs L-log entries If we press G -- GTID Report Master Information ------------------ Binary Log File Position Binlog_Do_DB Binlog_Ignore_DB mysql-bin.000001 571 GTID Executed Set 2A67DE00-2DA1-11E2-A711-00764F2BE90F:1-7 [...] Master GTID Executed Set +-------------------------------------------+ | gtid | +-------------------------------------------+ | 2A67DE00-2DA1-11E2-A711-00764F2BE90F:1-7 | | 5503D37E-2DB2-11E2-A781-8077D4C14B33:1-3 | +-------------------------------------------+ 14
  • 15. Failover? Failover starting... # Candidate slave localhost:3332 will become the new master. # Preparing candidate for failover. # Creating replication user if it does not exist. # Stopping slaves. # Performing STOP on all slaves. # Switching slaves to new master. # Starting slaves. # Performing START on all slaves. # Checking slaves for errors. # Failover complete. # Discovering slaves for master at localhost:3332 Failover console will restart in 5 seconds. 15
  • 16. Failed over!! MySQL Replication Monitor and Failover Utility Failover Mode = auto Next Interval = Mon Mar 19 16:05:12 2012 Master Information ------------------ Binary Log File Position Binlog_Do_DB Binlog_Ignore_DB mysql-bin.000001 1117 GTID Executed Set 2A67DE00-2DA1-11E2-A711-00764F2BE90F:1-7 [...] UUIDs +------------+-------+---------+--------+------------+---------+ | host | port | role | state | gtid_mode | health | +------------+-------+---------+--------+------------+---------+ | localhost | 3332 | MASTER | UP | ON | OK | | localhost | 3333 | SLAVE | UP | ON | OK | | localhost | 3334 | SLAVE | UP | ON | OK | +------------+-------+---------+--------+------------+---------+ 16
  • 17. Compare Two Databases and Identify Differences This utility compares the objects and data from two databases to find differences. It identifies objects having different definitions in the two databases and presents them in a diff-style format of choice. Differences in the data are shown using a similar diff-style format. Changed or missing rows are shown in a standard format of GRID, CSV, TAB, or VERTICAL. ‘But it works in test!!’ 17
  • 18. mysqldbcompare --server1=root@localhost emp1:emp2 --run- all-tests # server1 on localhost: ... connected. # Checking databases emp1 on server1 and emp2 on server2 # # WARNING: Objects in server2:emp2 but not in server1:emp1: # TRIGGER: trg # PROCEDURE: p1 # TABLE: t1 # VIEW: v1 # 18
  • 19. mysqldbcompare --server1=root@localhost emp1:emp2 --run- all-tests continued # Data differences found among rows: --- emp1.departments +++ emp2.departments @@ -1,4 +1,4 @@ ************************* 1. row ************************* dept_no: d002 - dept_name: dunno + dept_name: Finance 1 rows. 19
  • 20. mysqldbcompare --server1=root@localhost emp1:emp2 --run- all-tests continued even more! # Rows in emp1.departments not in emp2.departments ************************* 1. row ************************* dept_no: d008 dept_name: Research 1 rows. # Rows in emp2.departments not in emp1.departments ************************* 1. row ************************* dept_no: d100 dept_name: stupid 1 rows. 20
  • 21. mysqldbcompare --server1=root@localhost emp1:emp2 --run- all-tests continued even more again!! # TABLE dept_manager pass pass - # - Compare table checksum pass # Database consistency check failed. # # ...done 21
  • 22. Disk Usage shell> mysqldiskusage --server=root@localhost employees test # Source on localhost: ... connected. # Database totals: +------------+--------------+ | db_name | total | +------------+--------------+ | employees | 205,979,648 | | test | 4,096 | +------------+--------------+ Total database disk usage = 205,983,744 bytes or 196.00 MB #...done. 22
  • 23. shell> mysqldiskusage --server=root@localhost --format=csv -a -vv # Source on localhost: ... connected. # Database totals: db_name,db_dir_size,data_size,misc_files,total test1,0,0,0,0 db3,0,0,0,0 db2,0,0,0,0 db1,0,0,0,0 backup_test,19410,1117,18293,19410 employees,242519463,205979648,242519463,448499111 mysql,867211,657669,191720,849389 t1,9849,1024,8825,9849 test,56162,4096,52066,56162 util_test_a,19625,2048,17577,19625 util_test_b,17347,0,17347,17347 util_test_c,19623,2048,17575,19623 23
  • 24. mysqlindexcheck — Identify Potentially Redundant Table Indexes shell> mysqlindexcheck --server=root@localhost employees # Source on localhost: ... connected. # The following indexes are duplicates or redundant for table employees.dept_emp: # CREATE INDEX emp_no ON employees.dept_emp (emp_no) USING BTREE # may be redundant or duplicate of: ALTER TABLE employees.dept_emp ADD PRIMARY KEY (emp_no, dept_no) # The following indexes are duplicates or redundant for table employees.dept_manager: # CREATE INDEX emp_no ON employees.dept_manager (emp_no) USING BTREE # may be redundant or duplicate of: ALTER TABLE employees.dept_manager ADD PRIMARY KEY (emp_no, dept_no) # The following indexes are duplicates or redundant for table employees.salaries: # 24
  • 25. 25 shell> mysqluserclone --source=root@localhost --destination=root@localhost joe@localhost sam:secret1@localhost sally:secret2@localhost # Source on localhost: ... connected. # Destination on localhost: ... connected. # Cloning 2 users... # Cloning joe@localhost to user sam:secret1@localhost # Cloning joe@localhost to user sally:secret2@localhost # ...done. Note: SYS Schema (MySQL 5.6/7) allows you to find redundant indexes, queries running without indexes, and help your spot queries that may need indexes.
  • 26. 26 Check Grants -- who has permission to do what shell> mysqlgrants --server=user:pass@localhost:3310 --show=user_grants util_test util_test.t3 util_test.t2 util_test.t1 util_test.p1 util_test.f1 # DATABASE `util_test`: # - 'joe'@'user' : ALL PRIVILEGES # - 'joe_wildcard'@'%' : ALL PRIVILEGES # - 'priv_test_user'@'%' : EXECUTE, GRANT OPTION, SELECT, TRIGGER, UPDATE # - 'priv_test_user2'@'%' : EXECUTE, SELECT, UPDATE # - 'priv_test_user3'@'%' : ALTER ROUTINE, DELETE, DROP, EXECUTE, TRIGGER, UPDATE # TABLE `util_test`.`t1`: # - 'joe'@'user' : ALL PRIVILEGES # - 'joe_wildcard'@'%' : ALL PRIVILEGES # - 'priv_test_user'@'%' : GRANT OPTION, SELECT, TRIGGER, UPDATE # - 'priv_test_user2'@'%' : ALL PRIVILEGES, GRANT OPTION # - 'priv_test_user3'@'%' : DELETE, DROP, TRIGGER, UPDATE
  • 27. shell> mysqlgrants --server=user:pass@localhost:3310 --show=raw util_test util_test.t3 util_test.t2 util_test.t1 util_test.p1 util_test.f1 # DATABASE `util_test`: # - For 'joe'@'user' GRANT ALL PRIVILEGES ON `util_test`.* TO 'joe'@'user' # - For 'joe_wildcard'@'%' GRANT ALL PRIVILEGES ON `util_test`.* TO 'joe_wildcard'@'%' # - For 'priv_test_user'@'%' GRANT EXECUTE, TRIGGER ON `util_test`.* TO 'priv_test_user'@'%' WITH GRANT OPTION GRANT SELECT, UPDATE ON *.* TO 'priv_test_user'@'%' # - For 'priv_test_user2'@'%' GRANT SELECT, UPDATE, SHUTDOWN, EXECUTE ON *.* TO 'priv_test_user2'@'%' # - For 'priv_test_user3'@'%' GRANT DROP, EXECUTE, TRIGGER ON *.* TO 'priv_test_user3'@'%' GRANT UPDATE, DELETE, ALTER ROUTINE ON `util_test`.* TO 'priv_test_user3'@'%' 27
  • 28. Find all objects with a name that matches the pattern 't_' (the letter t followed by any single character) 28 shell> mysqlmetagrep --pattern="t_" --server=john@localhost +------------------------+--------------+--------------+-----------+ | Connection | Object Type | Object Name | Database | +------------------------+--------------+--------------+-----------+ | john:*@localhost:3306 | TABLE | t1 | test | | john:*@localhost:3306 | TABLE | t2 | test | | john:*@localhost:3306 | TABLE | tm | test | +------------------------+--------------+--------------+-----------+
  • 29. shell> mysqlmetagrep -b --pattern="%t2%" -- server=john@localhost:3306 +------------------------+--------------+--------------+-----------+ | Connection | Object Type | Object Name | Database | +------------------------+--------------+--------------+-----------+ | john:*@localhost:3306 | TRIGGER | tr_foo | test | | john:*@localhost:3306 | TABLE | t2 | test | +------------------------+--------------+--------------+-----------+ 29 QUESTION: Why is tr_foo listed here when the Object Name does not match “%t2%”????? Answer: the TRIGGER tr_foo’s body references the object ‘t2’
  • 30. Process control shell> mysqlprocgrep --server=root@localhost --match-command=sleep --age=1h --kill-connection You can remove MySQL queries that have been sleeping for one hour 30
  • 31. mysqluc 31 ...is part of MySQL Workbench (found under tools) and it gives you access to the MySQL Utilities And you can skip the first 5 letters of each command Mysqldbcopy = dbcopy
  • 32. Find process mysqluc> procgrep --sql --match-user=root --match-state=starting --print SELECT Id, User, Host, Db, Command, Time, State, Info FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER LIKE 'root' AND STATE LIKE 'starting' 32
  • 33. shell> mysqlprocgrep --kill-connection --sql-body --match-user=www-data --match-state=sleep DECLARE kill_done INT; DECLARE kill_cursor CURSOR FOR SELECT Id, User, Host, Db, Command, Time, State, Info FROM INFORMATION_SCHEMA.PROCESSLIST WHERE user LIKE 'www-data' AND State LIKE 'sleep' OPEN kill_cursor; BEGIN DECLARE id BIGINT; DECLARE EXIT HANDLER FOR NOT FOUND SET kill_done = 1; kill_loop: LOOP FETCH kill_cursor INTO id; KILL CONNECTION id; END LOOP kill_loop; END; CLOSE kill_cursor; 33
  • 34. Replication made easy - Are the settings good shell> mysqlrplcheck --master=root@host1:3310 -- slave=root@host2:3311 # master on host1: ... connected. # slave on host2: ... connected. Test Description Status ------------------------------------------------------------------------ Checking for binary logging on master [pass] Are there binlog exceptions? [pass] Replication user exists? [pass] Checking server_id values [pass] Is slave connected to master? [pass] Check master information file [pass] Checking InnoDB compatibility [pass] Checking storage engines compatibility [pass] Checking lower_case_table_names settings [pass] Checking slave delay (seconds behind master) [pass] 34
  • 35. See the topology shell> mysqlrplshow --master=root@localhost:3311 --recurse -- discover-slaves-ln=rootogi # master on localhost: ... connected. # Finding slaves for master: localhost:3311 # Replication Topology Graph localhost:3311 (MASTER) | +--- localhost:3310 - (SLAVE) | +--- localhost:3312 - (SLAVE + MASTER) | +--- localhost:3313 - (SLAVE) 35
  • 36. Cloneshell> mkdir /source/test123 shell> mysqlserverclone --server=root:pass@localhost --new-data=/Users/cbell/source/test123 --new-port=3310 --root-password=pass --mysqld=--log-bin=mysql-bin # Cloning the MySQL server running on localhost. # Creating new data directory... # Configuring new instance... # Locating mysql tools... # Setting up empty database and mysql tables... # Starting new instance of the server... # Testing connection to new instance... # Success! # Setting the root password... # ...done. 36
  • 37. 37 shell> mysqlrplms --slave=root:root@localhost:3306 --masters=root:root@localhost:3307,root:root@localhost:3308 # Starting multi-source replication... # Press CTRL+C to quit. # Switching to master 'localhost:3307'. # master on localhost: ... connected. # slave on localhost: ... connected. # # Current Master Information: +-------------------+-----------+---------------+-------------------+ | Binary Log File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +-------------------+-----------+---------------+-------------------+ | clone-bin.000001 | 594 | N/A | N/A | +-------------------+-----------+---------------+-------------------+ # GTID Executed Set: 00a4e027-a83a-11e3-8bd6-28d244017f26:1-2 # # Health Status: +------------+-------+---------+--------+------------+---------+ | host | port | role | state | gtid_mode | health | +------------+-------+---------+--------+------------+---------+ | localhost | 3307 | MASTER | UP | ON | OK | | localhost | 3306 | SLAVE | UP | ON | OK | | localhost | 3308 | MASTER | UP | ON | OK | +------------+-------+---------+--------+------------+---------+
  • 38. 38 shell> mysqlrpladmin --master=root@localhost:3331 --slaves=root@localhost:3332,root@localhost:3333,root@localhost:3334 --candidates=root@localhost:3333,root@localhost:3334 elect # Electing candidate slave from candidate list then slaves list. # Best slave found is located on localhost:3332. # ...done. List Candidate Slaves
  • 39. Skips a GTID Transaction shell> mysqlslavetrx --gtid-set=af6b22ee-7b0b-11e4-aa8d- 606720440b68:7-9 -- slaves=user:pass@localhost:3311,user:pass@localhost:3312 WARNING: Using a password on the command line interface can be insecure. # # GTID set to be skipped for each server: # - localhost@3311: af6b22ee-7b0b-11e4-aa8d-606720440b68:7-9 # - localhost@3312: af6b22ee-7b0b-11e4-aa8d-606720440b68:7-9 # # Injecting empty transactions for 'localhost:3311'... # Injecting empty transactions for 'localhost:3312'... # #...done. 39
  • 40. Extending Easy to extend with a very nice example in the docs. All utils use a three tier organization and support on the Utilities section of Forums.MySQL.Com http://forums.mysql.com/list.php?144 How to at: https://dev.mysql.com/doc/mysql-utilities/1.6/en/mysql-utils-intro-developers.html 40
  • 41. Other Recommended Tools MySQL Workbench https://dev.mysql.com/downloads/workbench/ Percona Toolkit https://www.percona.com/software/database-tools/percona-toolkit 41
  • 42. Dave Stokes - MySQL Community Manager David.Stokes@Oracle.Com @Stoker slideshare.net/davidmstokes Elephantanddolphin.blogger.com or opensourcedba.wordpress.com 42