Your SlideShare is downloading. ×
0
1Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Basic MySQL
Troubleshooting for Oracle
DBAs
Sveta Smirnova
Principal Technical Support Engineer

2Copyright © 2013, Oracle...
Program Agenda
 Introduction
 Basic single-client issues
 Concurrency issues
 High availability solutions
 Tools

3Co...
Introduction
Insert Picture Here

4Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
MySQL architecture
Overview
Base
●
Installation layout
●
Log files
Connectors
●
Clients
●
APIs
Optimizer
Caches & buffers
...
Typical installation layout

Datadir
●
Schema
●
Table files: *frm, *ibd, *MYD, *MYI, *par, etc.
●

Log files

●

InnoDB sh...
Log files

General query log
Slow query log
Binary log
Relay log
Error log
InnoDB logs (and, probably, created by other st...
Connectors

Clients
●
MySQL CLI
●
MySQL Workbench
●
MySQL Enterprise Monitor (MEM)
●
For administrators
APIs
●

Exist for ...
Plugins

Plugins
●
Storage engine
●
Full-text parsers
●
Daemon
●
INFORMATION_SCHEMA
●
Semisynchronous Replication
●
Audit
...
Storage engines

From troubleshooting point of view
●

Own data/index format

●

Own locking model

●

Own diagnostic

●

...
Basic single-client issues
Insert Picture Here

11Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
MySQL Access Privilege System

No roles by default, limited user limits
All records are in the mysql database (schema)
Plu...
Error handling
Errors vs warnings
mysql> select max (f1) from t1;
ERROR 1630 (42000): FUNCTION test.max does not exist. Ch...
Error handling
Application (C API)
Error information
●
mysql_errno
●
mysql_error
Warnings
●
mysql_info
●
mysql_sqlstate
●
...
Error handling
perror
[sveta@delly ~]$ perror 1630
MySQL error code 1630 (ER_FUNC_INEXISTENT_NAME_COLLISION): 
FUNCTION %s...
Error handling
in stored routines
GET DIAGNOSTICS
●
GET DIAGNOSTICS rows = ROW_COUNT, conditions = NUMBER;
●
GET DIAGNOSTI...
Options

Have global and session scope
Can be set
●
In configuration files
●
Command line parameter
●
SET [GLOBAL] var_nam...
Options

Allocated at
●
Server startup
●
User connection creation
●
For certain operations
To watch status
●
SHOW [GLOBAL]...
INFORMATION_SCHEMA

Contain metadata information
●
Tables
●
Indexes
●
Other
Allows to create plugins
●
InnoDB plugins
●
We...
Optimizer

EXPLAIN is less powerful if compare with Oracle
●
It is improved in version 5.7.3
●
Graphic EXPLAIN in MySQL Wo...
EXPLAIN in Oracle
http://docs.oracle.com/cd/B10500_01/server.920/a96533/ex_plan.htm
EXPLAIN PLAN SET statement_id = 'examp...
EXPLAIN in MySQL
mysql> EXPLAIN SELECT user, host FROM userG
*************************** 1. row **************************...
EXPLAIN in MySQL

EXPLAIN EXTENDED
●
Follow by SHOW WARNINGS
EXPLAIN PARTITIONS
EXPLAIN FORMAT=JSON

http://www.slideshare...
Storage engine specifics

They care about physical data, so all data information are on their level
●
Corruption
●
Index s...
Storage engine specifics
MyISAM
Stores data in files
●
*frm – table definition, common for all storage engines
●
*MYD – da...
Storage engine specifics
InnoDB
Transactional storage engine
Physical layout
●
*frm file – table definition
●
Shared table...
Concurrency issues
Insert Picture Here

27Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Lock types

MDL locks
Table locks
Row locks
Read locks
●
Block writes
Write locks
●
Block both read and writes

28Copyrigh...
Transactions and Their Relationship With Locks

Server-level
●
MDL locks
Engine level
●
Table locks
●
Row locks
AUTOCOMMIT...
Diagnostic Tools

SHOW [FULL] PROCESSLIST
●
Universal tool which lists all currently running connections
SHOW ENGINE INNOD...
SHOW PROCESSLIST

mysql> show processlist;
+­­­­+­­­­­­­+­­­­­­­­­­­+­­­­­­+­­­­­­­­­+­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­...
INFORMATION_SCHEMA.PROCESSLIST
structure
mysql> DESCRIBE INFORMATION_SCHEMA.PROCESSLIST;
+­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­...
SHOW PROCESSLIST and Transactions

mysql> show processlist;
+­­­­+­­­­­­­+­­­­­­­­­­­+­­­­­­­­­+­­­­­­­­­+­­­­­­­­­­+­­­­­...
Storage engine specifics

Transactions and engine-level locks are done at the engine level
Storage engines have own diagno...
Storage engine specifics
InnoDB
InnoDB Monitors
●
SHOW ENGINE INNODB STATUS
●
Lock Monitor
INFORMATION_SCHEMA tables
●
INN...
Diagnostics: P_S

Monitors internal operations
●
Events
●
Waits
●
Mutexes
●
Statements
●
Stages
Similar to Oracle wait int...
MDL Locks

Waiting thread only
SHOW PROCESSLIST, INFORMATION_SCHEMA.PROCESSLIST
●
Waiting for table metadata lock
Performa...
Performance Schema MDL queries
mysql> SELECT * FROM mutex_instances WHERE 
LOCKED_BY_THREAD_ID 
IS NOT NULLG
*************...
Performance Schema MDL queries
mysql> SELECT THREAD_ID, EVENT_ID, EVENT_NAME, SOURCE, TIMER_START, 
OBJECT_INSTANCE_BEGIN,...
High availability solutions
Insert Picture Here

40Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
MySQL Cluster

Special storage engine: NDB
Stores data on two or more physical machines
Two or more copies
General trouble...
Replication
Overview
Always available, but you must setup it before use
Asynchronous master-slave
Master
●
Keeps all updat...
Replication
Troubleshooting tools
Error log file
Slave
●
SHOW SLAVE STATUS
Master
●
SHOW MASTER STATUS
mysqlbinlog

43Copy...
Tools
Insert Picture Here

44Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
For developers

MySQL Workbench
●
SQL editor
●
Database designer
●
Introduction to MySQL Database Development with MySQL W...
For DBA

MySQL Enterprise Monitor
●
Real-time MySQL performance and availability monitoring
●
Error information
●
Advisors...
For DBA

MySQL Workbench
●
Server administration
●
Backups
●
Using the New MySQL Workbench Tools for Performance Tuning
[H...
Command line
  They are not
Set of tools to do various administrative job
Same!
●
MySQL Workbench Utilities
●
http://dev.m...
Command line

MySQL Sandbox
●
Sandbox for your tests
●
https://launchpad.net/mysql-sandbox
PS_HELPER view
●
www.markleith....
References

MySQL User Reference Manual
●
http://dev.mysql.com/doc/refman/5.6/en/index.html
Knowledge Management Database
...
References

MySQL Troubleshooting book
●
http://shop.oreilly.com/product/0636920021964.do
Marc Alff's Performance Schema b...
?
Insert Picture Here

52Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
THANK YOU!
https://twitter.com/#!/svetsmirnova
https://blogs.oracle.com/svetasmirnova/

53Copyright © 2013, Oracle and/or ...
Graphic Section Divider

54Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
The preceding is intended to outline our general product
direction. It is intended for information purposes only, and may
...
MySQL Troubleshooting for
Oracle DBAs
Part II: details
Sveta Smirnova
Principal Technical Support Engineer

56Copyright © ...
Replication
Insert Picture Here

57Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Replication IO thread:
communication issues
Access error
●
Check slave error log
●
SHOW SLAVE STATUS
●
Try to connect usin...
Replication SQL thread:
typical issues
Simple master-slave
●
Data is different on master and slave
●
Replication event can...
Replication SQL thread:
Data is different on master and slave
Was the table modified besides the SQL thread?
●
How?
●
Can ...
Replication SQL thread:
Events from master were applied in wrong order
Lock issues
●
InnoDB
Triggers
●
SET GLOBAL slave_sk...
Replication SQL thread:
Slave lags far behind the master
Threads
●
Master runs in multiple update threads
●
Slave uses sin...
Optimizer
Insert Picture Here

63Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Optimizer
Handler_% status variables
mysql> flush status;
Query OK, 0 rows affected (0.00 sec)
mysql> SHOW STATUS LIKE 'Ha...
Optimizer
Handler_% status variables
| Handler_read_rnd_next      | 0     |
| Handler_rollback           | 0     |
| Handl...
Optimizer
Handler_% status variables
mysql> SHOW STATUS LIKE 'Handler_%';
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­+
| Variab...
Optimizer
INFORMATION_SCHEMA.OPTIMIZER_TRACE
Variables:
●
optimizer_trace=”enabled=on|off,one_line=off|on”
●
optimizer_tra...
Optimizer
INFORMATION_SCHEMA.OPTIMIZER_TRACE
Turn tracing on (it's off by default):
SET optimizer_trace="enabled=on";
SELE...
Optimizer
INFORMATION_SCHEMA.OPTIMIZER_TRACE
mysql> SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACEG
********************...
Optimizer
INFORMATION_SCHEMA.TRACE
join_preparation
join_optimization
●
table_dependencies
●
rows_estimation
●
considered_...
Options
Insert Picture Here

71Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Options
Scope
Global
●
Control parameters, necessary for all server processes
●
Location of server files: datadir etc.
●

...
Options
How to set
SET [GLOBAL] var_name = NEW_VAL
Command line option
Configuration file
●
In default location
●
Specifie...
Options
Who can change
Global options and few session options
●
A user with privilege SUPER
Session options
●
Anybody
Ther...
Options
When allocated
Those which control behavior of whole server
●
Once at server startup
●
Can start with low values, ...
Options
How to control
SHOW [GLOBAL] STATUS
GLOBAL
●
Since server start
SESSION
●
For operations in current session
●
Can ...
Options
Global example
mysql> show global status like 'Handler_read_rnd_next';
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­...
Options
Session example
mysql> show status like 'Handler_read_rnd_next';
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­+
| Var...
Options
Troubleshooting best practices
Record currently used variables
●
SHOW [GLOBAL] VARIABLES
Make change dynamically i...
Options
When affecting option is not known
Record currently used variables
●
SHOW [GLOBAL] VARIABLES
Start mysqld with opt...
InnoDB Monitors and
Information Schema tables

81Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Ins...
SHOW ENGINE INNODB STATUS
­­­­­­­­­­­­
TRANSACTIONS
­­­­­­­­­­­­
Trx id counter 1B1C
Purge done for trx's n:o < 1B19 undo ...
SHOW ENGINE INNODB STATUS
­­­TRANSACTION 1B1B, ACTIVE 6 sec starting index read
mysql tables in use 1, locked 1
LOCK WAIT ...
SHOW ENGINE INNODB STATUS

­­­TRANSACTION 1B19, ACTIVE 787 sec
2 lock struct(s), heap size 376, 1 row lock(s), undo log 
e...
InnoDB Monitors

Pseudo-tables
Turn periodical logging into error log
●
CREATE TABLE innodb_monitor(f1 int) ENGINE=INNODB;...
InnoDB Lock Monitor
­­­TRANSACTION 1B19, ACTIVE 1935 sec
2 lock struct(s), heap size 376, 1 row lock(s), undo log entries ...
InnoDB Information Schema tables

INNODB_TRX
INNODB_LOCKS
INNODB_LOCK_WAITS

87Copyright © 2013, Oracle and/or its affilia...
InnoDB Information Schema tables

mysql> SELECT * FROM INNODB_LOCK_WAITS;
+­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­+­­­­­­­­­­­...
InnoDB Information Schema tables

mysql> select trx_mysql_thread_id, trx_id from innodb_trx;
+­­­­­­­­­­­­­­­­­­­­­+­­­­­­...
MySQL Access Privilege
System

90Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Insert Picture Here
MySQL Access Privilege System
Overview
No roles by default, limited user limits
All records are in the mysql database (sch...
MySQL Access Privilege System
How to handle connection issues
SELECT user, host FROM mysql.user
Most descriptive host firs...
MySQL Access Privilege System
Sort order
mysql> select user, host from mysql.user order by user desc, host 
desc;
+­­­­­­+...
MySQL Access Privilege System
Wrong access
SHOW GRANTS [FOR user@host]
Grant tables
●

mysql.db

●

mysql.tables_priv

●

...
MySQL Access Privilege System
Grants
mysql> show grants;
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­...
MySQL Access Privilege System
Grants
mysql> show grants for foo@'%';;
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­...
THANK YOU!
https://twitter.com/#!/svetsmirnova
https://blogs.oracle.com/svetasmirnova/

97Copyright © 2013, Oracle and/or ...
Graphic Section Divider

98Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
The preceding is intended to outline our general product
direction. It is intended for information purposes only, and may
...
Upcoming SlideShare
Loading in...5
×

Basic MySQL Troubleshooting for Oracle DBAs

1,026

Published on

Presentation which I showed at MySQL Connect 2013

Published in: Technology, News & Politics
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,026
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
63
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Basic MySQL Troubleshooting for Oracle DBAs"

  1. 1. 1Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  2. 2. Basic MySQL Troubleshooting for Oracle DBAs Sveta Smirnova Principal Technical Support Engineer 2Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Picture Here
  3. 3. Program Agenda  Introduction  Basic single-client issues  Concurrency issues  High availability solutions  Tools 3Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  4. 4. Introduction Insert Picture Here 4Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  5. 5. MySQL architecture Overview Base ● Installation layout ● Log files Connectors ● Clients ● APIs Optimizer Caches & buffers Storage engines Management 5Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Picture Here
  6. 6. Typical installation layout Datadir ● Schema ● Table files: *frm, *ibd, *MYD, *MYI, *par, etc. ● Log files ● InnoDB shared tablespace Configurable 6Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  7. 7. Log files General query log Slow query log Binary log Relay log Error log InnoDB logs (and, probably, created by other storage engines) 7Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  8. 8. Connectors Clients ● MySQL CLI ● MySQL Workbench ● MySQL Enterprise Monitor (MEM) ● For administrators APIs ● Exist for most popular programming languages ● C, C++, JDBC, PHP, Python, Net, ODBC 8Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  9. 9. Plugins Plugins ● Storage engine ● Full-text parsers ● Daemon ● INFORMATION_SCHEMA ● Semisynchronous Replication ● Audit ● Authentication ● Password-validation 9Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  10. 10. Storage engines From troubleshooting point of view ● Own data/index format ● Own locking model ● Own diagnostic ● Own log files ● CHECK TABLE 10Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  11. 11. Basic single-client issues Insert Picture Here 11Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  12. 12. MySQL Access Privilege System No roles by default, limited user limits All records are in the mysql database (schema) Pluggable authentication since version 5.5 Connections: TCP/IP with login-password, socket (Unix), named pipe (Windows) SELECT user, host FROM mysql.user SELECT USER(), CURRENT_USER() SHOW GRANTS 12Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  13. 13. Error handling Errors vs warnings mysql> select max (f1) from t1; ERROR 1630 (42000): FUNCTION test.max does not exist. Check the  'Function Name Parsing and Resolution' section in the Reference Manual mysql> select * from t1 where "f1"=1; Empty set, 1 warning (0.05 sec) mysql> show warnings; +­­­­­­­­­­­+­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | Level     | Code   | Message                                            | +­­­­­­­­­­­+­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | Warning   | 1292   | Truncated incorrect DOUBLE value: 'f1'             | +­­­­­­­­­­­+­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 1 row in set (0.00 sec) 13Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  14. 14. Error handling Application (C API) Error information ● mysql_errno ● mysql_error Warnings ● mysql_info ● mysql_sqlstate ● mysql_warning_count 14Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  15. 15. Error handling perror [sveta@delly ~]$ perror 1630 MySQL error code 1630 (ER_FUNC_INEXISTENT_NAME_COLLISION):  FUNCTION %s does not exist. Check the 'Function Name Parsing and  Resolution' section in the Reference Manual [sveta@delly ~]$ perror 1292 MySQL error code 1292 (ER_TRUNCATED_WRONG_VALUE): Truncated  incorrect %­.32s value: '%­.128s' [sveta@delly ~]$ perror 2 OS error code   2:  No such file or directory [sveta@delly ~]$ perror 150 MySQL error code 150: Foreign key constraint is incorrectly  formed 15Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  16. 16. Error handling in stored routines GET DIAGNOSTICS ● GET DIAGNOSTICS rows = ROW_COUNT, conditions = NUMBER; ● GET DIAGNOSTICS CONDITION 1  code = RETURNED_SQLSTATE,  msg = MESSAGE_TEXT; http://dev.mysql.com/doc/refman/5.6/en/diagnostics-area.html 16Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  17. 17. Options Have global and session scope Can be set ● In configuration files ● Command line parameter ● SET [GLOBAL] var_name = NEW_VAL ● SHOW [GLOBAL] VARIABLES Only two built-in levels of write access ● SUPER for GLOBAL and limited SESSION variables ● Non-privileged user can change any session option! 17Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  18. 18. Options Allocated at ● Server startup ● User connection creation ● For certain operations To watch status ● SHOW [GLOBAL] STATUS http://dev.mysql.com/doc/refman/5.6/en/mysqld-option-tables.html 18Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  19. 19. INFORMATION_SCHEMA Contain metadata information ● Tables ● Indexes ● Other Allows to create plugins ● InnoDB plugins ● We will discuss them later Oracle analog: Data Dictionary Views 19Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  20. 20. Optimizer EXPLAIN is less powerful if compare with Oracle ● It is improved in version 5.7.3 ● Graphic EXPLAIN in MySQL Workbench 6.0 ● MySQL’s EXPLAIN Command New Features [HOL9734, passed] EXPLAIN EXTENDED INFORMATION_SCHEMA.OPTIMIZER_TRACE Status variables 'Handler_%' 20Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  21. 21. EXPLAIN in Oracle http://docs.oracle.com/cd/B10500_01/server.920/a96533/ex_plan.htm EXPLAIN PLAN SET statement_id = 'example_plan4' FOR SELECT h.order_number, l.revenue_amount, l.ordered_quantity   FROM so_headers_all h, so_lines_all l  WHERE h.customer_id = :b1    AND h.date_ordered > SYSDATE­30    AND l.header_id = h.header_id ; Plan ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ SELECT STATEMENT  NESTED LOOPS   TABLE ACCESS BY INDEX ROWID SO_HEADERS_ALL    INDEX RANGE SCAN SO_HEADERS_N1   TABLE ACCESS BY INDEX ROWID SO_LINES_ALL    INDEX RANGE SCAN SO_LINES_N1 21Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  22. 22. EXPLAIN in MySQL mysql> EXPLAIN SELECT user, host FROM userG *************************** 1. row ***************************            id: 1   select_type: SIMPLE         table: user          type: index possible_keys: NULL           key: PRIMARY       key_len: 228           ref: NULL          rows: 4         Extra: Using index 1 row in set (0.00 sec) 22Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  23. 23. EXPLAIN in MySQL EXPLAIN EXTENDED ● Follow by SHOW WARNINGS EXPLAIN PARTITIONS EXPLAIN FORMAT=JSON http://www.slideshare.net/SvetaSmirnova/troubleshooting-my-sqlperformanceaddonsen http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getCourseDesc?dc=D79908_1879034 http://dev.mysql.com/doc/refman/5.6/en/explain-output.html 23Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  24. 24. Storage engine specifics They care about physical data, so all data information are on their level ● Corruption ● Index statistics CHECK TABLE to check for errors 24Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  25. 25. Storage engine specifics MyISAM Stores data in files ● *frm – table definition, common for all storage engines ● *MYD – data file ● *MYI – index file myisamchk ­­myisam_recovery_options to check each time you open a table ● First access – table is opened ● Second, third, .. access – existent descriptor used ● FLUSH TABLES – closes opened descriptors 25Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  26. 26. Storage engine specifics InnoDB Transactional storage engine Physical layout ● *frm file – table definition ● Shared tablespace ● *ibd file – tablespace for individual table ● Optional: ­­innodb_file_per_table ● Recommended Redo log files OPTIMIZE TABLE = ALTER + ANALYZE Automatic startup check ● 26Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  27. 27. Concurrency issues Insert Picture Here 27Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  28. 28. Lock types MDL locks Table locks Row locks Read locks ● Block writes Write locks ● Block both read and writes 28Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  29. 29. Transactions and Their Relationship With Locks Server-level ● MDL locks Engine level ● Table locks ● Row locks AUTOCOMMIT ● Supported 29Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  30. 30. Diagnostic Tools SHOW [FULL] PROCESSLIST ● Universal tool which lists all currently running connections SHOW ENGINE INNODB STATUS INFORMATION SCHEMA ● PROCESSLIST ● InnoDB tables PERFORMANCE SCHEMA ● MDL locks Unlocking MySQL: Dealing with Locking in MySQL [CON4038, passed] 30Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  31. 31. SHOW PROCESSLIST mysql> show processlist; +­­­­+­­­­­­­+­­­­­­­­­­­+­­­­­­+­­­­­­­­­+­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+ | Id | User  | Host      | db   | Command | Time | State                        | Info           | +­­­­+­­­­­­­+­­­­­­­­­­­+­­­­­­+­­­­­­­­­+­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+ | 23 | sveta | localhost | test | Query   |   3  | User sleep                   | select *,  sleep(20) from tlog        | | 24 | sveta | localhost | test | Query   |   1  | Waiting for table level lock | update tlog set  ln=5 where ln=4  | | 28 | root  | localhost | NULL | Query   |   0  | NULL                         | show processlist                          | +­­­­+­­­­­­­+­­­­­­­­­­­+­­­­­­+­­­­­­­­­+­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+ 3 rows in set (0.00 sec) 31Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  32. 32. INFORMATION_SCHEMA.PROCESSLIST structure mysql> DESCRIBE INFORMATION_SCHEMA.PROCESSLIST; +­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­+­­­­­­­+­­­­­­+­­­­­­­­­­+­­­­­­­­+ | Field          | Type            | Null   | Key | Default  | Extra  | +­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­+­­­­­­­+­­­­­­+­­­­­­­­­­+­­­­­­­­+ | ID             | bigint(4)       | NO    |      | 0        |        | | USER           | varchar(16)     | NO    |      |          |        | | HOST           | varchar(64)     | NO    |      |          |        | | DB             | varchar(64)     | YES   |      | NULL     |        | | COMMAND        | varchar(16)     | NO    |      |          |        | | TIME           | int(7)          | NO    |      | 0        |        | | STATE          | varchar(64)     | YES   |      | NULL     |        | | INFO           | longtext        | YES   |      | NULL     |        | +­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­+­­­­­­+­­­­­­­­­­+­­­­­­­+ 32Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  33. 33. SHOW PROCESSLIST and Transactions mysql> show processlist; +­­­­+­­­­­­­+­­­­­­­­­­­+­­­­­­­­­+­­­­­­­­­+­­­­­­­­­­+­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | Id | User  | Host      | db      | Command | Time     | State    | Info                                | +­­­­+­­­­­­­+­­­­­­­­­­­+­­­­­­­­­+­­­­­­­­­+­­­­­­­­­­+­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | 28 | root  | localhost | NULL    | Query   |    0     | NULL     | show processlist                    | | 31 | sveta | localhost | test    | Query   |    7     | Updating | update tlog set eid=2345 where ln=1 | | 32 | sveta | localhost | test    | Sleep   |   18     |          | NULL                                | +­­­­+­­­­­­­+­­­­­­­­­­­+­­­­­­­­­+­­­­­­­­­+­­­­­­­­­­+­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 3 rows in set (0.00 sec) Not much info! 33Copyright © 2013, Oracle and/or its affiliates. All rights reserved. No lock information!
  34. 34. Storage engine specifics Transactions and engine-level locks are done at the engine level Storage engines have own diagnostic tools Use them when hit an issue with such a lock 34Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  35. 35. Storage engine specifics InnoDB InnoDB Monitors ● SHOW ENGINE INNODB STATUS ● Lock Monitor INFORMATION_SCHEMA tables ● INNODB_TRX ● INNODB_LOCKS ● INNODB_LOCK_WAITS 35Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  36. 36. Diagnostics: P_S Monitors internal operations ● Events ● Waits ● Mutexes ● Statements ● Stages Similar to Oracle wait interface Improving Performance with MySQL Performance Schema [HOL9733, Sunday, 1:00 PM] Making the Performance Schema Easier to Use [CON5282, Sunday, 10:00 AM] Performance Schema and ps_helper [CON4077, passed] 36Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  37. 37. MDL Locks Waiting thread only SHOW PROCESSLIST, INFORMATION_SCHEMA.PROCESSLIST ● Waiting for table metadata lock Performance Schema ● MUTEX_INSTANCES ● EVENTS_WAITS_CURRENT ● THREADS 37Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  38. 38. Performance Schema MDL queries mysql> SELECT * FROM mutex_instances WHERE  LOCKED_BY_THREAD_ID  IS NOT NULLG *********************** 1. row ***********************                  NAME:  wait/synch/mutex/sql/MDL_wait::LOCK_wait_status OBJECT_INSTANCE_BEGIN: 37104744   LOCKED_BY_THREAD_ID: 18 1 row in set (0.01 sec) 38Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  39. 39. Performance Schema MDL queries mysql> SELECT THREAD_ID, EVENT_ID, EVENT_NAME, SOURCE, TIMER_START,  OBJECT_INSTANCE_BEGIN, OPERATION FROM events_waits_current WHERE  THREAD_ID IN(SELECT LOCKED_BY_THREAD_ID FROM mutex_instances WHERE  LOCKED_BY_THREAD_ID IS NOT NULL)G *************************** 1. row ***************************             THREAD_ID: 18              EVENT_ID: 461            EVENT_NAME: wait/synch/cond/sql/MDL_context::COND_wait_status                SOURCE: mdl.cc:1210           TIMER_START: 97623253523306 OBJECT_INSTANCE_BEGIN: 0             OPERATION: timed_wait 1 row in set (0.00 sec) 39Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  40. 40. High availability solutions Insert Picture Here 40Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  41. 41. MySQL Cluster Special storage engine: NDB Stores data on two or more physical machines Two or more copies General troubleshooting techniques ● Applicable Specific NDB storage engine techniques 41Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  42. 42. Replication Overview Always available, but you must setup it before use Asynchronous master-slave Master ● Keeps all updates in separate file: binary log Slave ● IO thread read updates from master and stores in relay log file ● SQL thread executes updates 42Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  43. 43. Replication Troubleshooting tools Error log file Slave ● SHOW SLAVE STATUS Master ● SHOW MASTER STATUS mysqlbinlog 43Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  44. 44. Tools Insert Picture Here 44Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  45. 45. For developers MySQL Workbench ● SQL editor ● Database designer ● Introduction to MySQL Database Development with MySQL Workbench [CON3967, Sunday, 5:30 PM] MySQL Command line client ● Command-line interface for SQL ● SELECT, INSERT, UPDATE, DELETE, etc. 45Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  46. 46. For DBA MySQL Enterprise Monitor ● Real-time MySQL performance and availability monitoring ● Error information ● Advisors ● Forcasts 46Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  47. 47. For DBA MySQL Workbench ● Server administration ● Backups ● Using the New MySQL Workbench Tools for Performance Tuning [HOL9786, passed] MySQL command line client ● Command-line interface for SQL ● GRANT, CREATE, OPTIMIZE, etc. mysqladmin 47Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  48. 48. Command line   They are not Set of tools to do various administrative job Same! ● MySQL Workbench Utilities ● http://dev.mysql.com/downloads/tools/utilities/ ● ● Development of Fault-Tolerant Failover Tools with MySQL Utilities [CON4276, Sunday, 2:30 PM] Percona Toolkit ● http://www.percona.com/software/percona-toolkit 48Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  49. 49. Command line MySQL Sandbox ● Sandbox for your tests ● https://launchpad.net/mysql-sandbox PS_HELPER view ● www.markleith.co.uk/ps_helper/ ● Performance Schema and ps_helper [CON4077, passed] 49Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  50. 50. References MySQL User Reference Manual ● http://dev.mysql.com/doc/refman/5.6/en/index.html Knowledge Management Database Forums ● http://forums.mysql.com Bug trackers ● http://bugs.mysql.com ● Oracle Internal Bugs database My Oracle Support ● https://support.oracle.com 50Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  51. 51. References MySQL Troubleshooting book ● http://shop.oreilly.com/product/0636920021964.do Marc Alff's Performance Schema blog ● http://marcalff.blogspot.ru/ Planet MySQL ● http://planet.mysql.com/ ● http://dev.mysql.com/support/blogs/ ● https://blogs.oracle.com/mysqlinnodb/ 51Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  52. 52. ? Insert Picture Here 52Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  53. 53. THANK YOU! https://twitter.com/#!/svetsmirnova https://blogs.oracle.com/svetasmirnova/ 53Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Picture Here
  54. 54. Graphic Section Divider 54Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  55. 55. The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 55Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  56. 56. MySQL Troubleshooting for Oracle DBAs Part II: details Sveta Smirnova Principal Technical Support Engineer 56Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Picture Here
  57. 57. Replication Insert Picture Here 57Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  58. 58. Replication IO thread: communication issues Access error ● Check slave error log ● SHOW SLAVE STATUS ● Try to connect using normal MySQL client using slave credentials ● SHOW GRANTS ● ● Fix privileges on master Restart slave 58Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  59. 59. Replication SQL thread: typical issues Simple master-slave ● Data is different on master and slave ● Replication event can not be applied Different errors on master and slave ● Slave lags far behind the master Circular replication or other writes in addition to slave SQL thread ● Data is different on master and slave ● 59Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  60. 60. Replication SQL thread: Data is different on master and slave Was the table modified besides the SQL thread? ● How? ● Can it affect content of the table in the wrong way? Are the table definitions same on master and slave? Is it possible that master events was applied in wrong order? ● Use mysqlbinlog to find queries which caused the issue ● Check master's application to find what is wrong 60Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  61. 61. Replication SQL thread: Events from master were applied in wrong order Lock issues ● InnoDB Triggers ● SET GLOBAL slave_skip_counter ● Synchronize tables! Different options ● Start slave with master's options, then check 61Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  62. 62. Replication SQL thread: Slave lags far behind the master Threads ● Master runs in multiple update threads ● Slave uses single Seconds_behind_master is growing Tune slave performance ● Buffers ● Indexes (for statement) 62Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  63. 63. Optimizer Insert Picture Here 63Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  64. 64. Optimizer Handler_% status variables mysql> flush status; Query OK, 0 rows affected (0.00 sec) mysql> SHOW STATUS LIKE 'Handler_%'; +­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­+ | Variable_name              | Value | +­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­+ | Handler_commit             | 0     | | Handler_delete             | 0     | | Handler_discover           | 0     | | Handler_prepare            | 0     | | Handler_read_first         | 0     | | Handler_read_key           | 0     | | Handler_read_last          | 0     | | Handler_read_next          | 0     | | Handler_read_prev          | 0     | | Handler_read_rnd           | 0     | 64Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  65. 65. Optimizer Handler_% status variables | Handler_read_rnd_next      | 0     | | Handler_rollback           | 0     | | Handler_savepoint          | 0     | | Handler_savepoint_rollback | 0     | | Handler_update             | 0     | | Handler_write              | 0     | +­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­+ 16 rows in set (0.00 sec) mysql> select count(*) from employees  join titles using(emp_no) where title='Senior Engineer'; +­­­­­­­­­­+ | count(*) | +­­­­­­­­­­+ |    97750 | +­­­­­­­­­­+ 1 row in set (3.24 sec) 65Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  66. 66. Optimizer Handler_% status variables mysql> SHOW STATUS LIKE 'Handler_%'; +­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­+ | Variable_name              | Value  | +­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­+ | Handler_commit             | 1      | | Handler_delete             | 0      | | Handler_discover           | 0      | | Handler_prepare            | 0      | | Handler_read_first         | 1      | | Handler_read_key           | 300027 | | Handler_read_last          | 0      | | Handler_read_next          | 397774 | | Handler_read_prev          | 0      | | Handler_read_rnd           | 0      | | Handler_read_rnd_next      | 0      | ... 66Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  67. 67. Optimizer INFORMATION_SCHEMA.OPTIMIZER_TRACE Variables: ● optimizer_trace=”enabled=on|off,one_line=off|on” ● optimizer_trace_features=”greedy_search=on,range_optimi zer=on,dynamic_range=on,repeated_subselect=on” ● optimizer_trace_limit=1 ● optimizer_trace_max_mem_size=16384 ● optimizer_trace_offset=­1 ● end_markers_in_json=0|1 67Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  68. 68. Optimizer INFORMATION_SCHEMA.OPTIMIZER_TRACE Turn tracing on (it's off by default): SET optimizer_trace="enabled=on"; SELECT <your query here>;  SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; More queries... When done with tracing, disable it: SET optimizer_trace="enabled=off"; http://dev.mysql.com/doc/internals/en/optimizer-tracing.html 68Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  69. 69. Optimizer INFORMATION_SCHEMA.OPTIMIZER_TRACE mysql> SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACEG *************************** 1. row ***************************                         QUERY: select emp_no, min(from_date) from titles  group by emp_no limit 10                         TRACE: {   "steps": [     {       "join_preparation": {         "select#": 1,         "steps": [           {             "expanded_query": "/* select#1 */ select `titles`.`emp_no` AS  `emp_no`,min(`titles`.`from_date`) AS `min(from_date)` from `titles` group  by `titles`.`emp_no` limit 10" 69Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  70. 70. Optimizer INFORMATION_SCHEMA.TRACE join_preparation join_optimization ● table_dependencies ● rows_estimation ● considered_execution_plans ● attaching_conditions_to_tables ● clause_processing ● refine_plan ● reconsidering_access_paths_for_index_ordering join_execution 70Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  71. 71. Options Insert Picture Here 71Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  72. 72. Options Scope Global ● Control parameters, necessary for all server processes ● Location of server files: datadir etc. ● Shared buffers ● More Session ● Control connection-specific parameters http://dev.mysql.com/doc/refman/5.6/en/mysqld-option-tables.html 72Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  73. 73. Options How to set SET [GLOBAL] var_name = NEW_VAL Command line option Configuration file ● In default location ● Specified by option ­­defaults­file 73Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  74. 74. Options Who can change Global options and few session options ● A user with privilege SUPER Session options ● Anybody There is no limits! 74Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  75. 75. Options When allocated Those which control behavior of whole server ● Once at server startup ● Can start with low values, then grow to specified Connection options ● For every connection when connection opens Operation-specific ● For every operation when needed 75Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  76. 76. Options How to control SHOW [GLOBAL] STATUS GLOBAL ● Since server start SESSION ● For operations in current session ● Can be reset ● FLUSH STATUS 76Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  77. 77. Options Global example mysql> show global status like 'Handler_read_rnd_next'; +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­+ | Variable_name                  | Value      | +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­+ | Handler_read_rnd_next          | 3821812    | +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­+ 1 row in set (0.00 sec) 77Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  78. 78. Options Session example mysql> show status like 'Handler_read_rnd_next'; +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­+ | Variable_name                  | Value  | +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­+ | Handler_read_rnd_next          | 8      | +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­+ 1 row in set (0.00 sec) 78Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  79. 79. Options Troubleshooting best practices Record currently used variables ● SHOW [GLOBAL] VARIABLES Make change dynamically if possible ● SET [GLOBAL] var_name=NEW_VAL Test in one session first Then change global variable Change configuration file after you are happy with results 79Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  80. 80. Options When affecting option is not known Record currently used variables ● SHOW [GLOBAL] VARIABLES Start mysqld with option –no­defaults ● This option must be first one! Check if problem is solved Change variable values one-by-one until you find one which leads to the problem 80Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  81. 81. InnoDB Monitors and Information Schema tables 81Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Picture Here
  82. 82. SHOW ENGINE INNODB STATUS ­­­­­­­­­­­­ TRANSACTIONS ­­­­­­­­­­­­ Trx id counter 1B1C Purge done for trx's n:o < 1B19 undo n:o < 0 History list length 189 LIST OF TRANSACTIONS FOR EACH SESSION: ­­­TRANSACTION 0, not started MySQL thread id 28, OS thread handle 0x7fa9301a0700, query  id 8653 localhost root show engine innodb status 82Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  83. 83. SHOW ENGINE INNODB STATUS ­­­TRANSACTION 1B1B, ACTIVE 6 sec starting index read mysql tables in use 1, locked 1 LOCK WAIT 2 lock struct(s), heap size 376, 1 row lock(s) MySQL thread id 31, OS thread handle 0x7fa9301e1700, query id 8652 localhost sveta Updating update tbllog set `Employee ID`=2345 where `Log Number`=1 ­­­­­­­ TRX HAS BEEN WAITING 6 SEC FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space id 0 page no 81967 n bits 72 index `PRIMARY` of table `test`.`tlog`  trx id 1B1B lock_mode X locks rec but not gap waiting Record lock, heap no 6 PHYSICAL RECORD: n_fields 5; compact format; info bits 0  0: len 4; hex 80000001; asc     ;;  1: len 6; hex 000000001b19; asc       ;;  2: len 7; hex 14000140340110; asc    @4  ;;  3: len 4; hex 80003039; asc   09;;  4: SQL NULL; 83Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  84. 84. SHOW ENGINE INNODB STATUS ­­­TRANSACTION 1B19, ACTIVE 787 sec 2 lock struct(s), heap size 376, 1 row lock(s), undo log  entries 1 MySQL thread id 32, OS thread handle 0x7fa930222700, query  id 8647 localhost sveta No lock information For the transaction Which holds the lock! 84Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  85. 85. InnoDB Monitors Pseudo-tables Turn periodical logging into error log ● CREATE TABLE innodb_monitor(f1 int) ENGINE=INNODB; Lock monitor ● Changes output format of InnoDB Monitor ● CREATE TABLE innodb_lock_monitor(f1 int) ENGINE=INNODB; 85Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  86. 86. InnoDB Lock Monitor ­­­TRANSACTION 1B19, ACTIVE 1935 sec 2 lock struct(s), heap size 376, 1 row lock(s), undo log entries 1 MySQL thread id 32, OS thread handle 0x7fa930222700, query id 8647 localhost sveta TABLE LOCK table `test`.`tlog` trx id 1B19 lock mode IX RECORD LOCKS space id 0 page no 81967 n bits 72 index `PRIMARY` of table  `test`.`tlog` trx id 1B19 lock_mode X locks rec but not gap Record lock, heap no 6 PHYSICAL RECORD: n_fields 5; compact format; info bits 0  0: len 4; hex 80000001; asc     ;;  1: len 6; hex 000000001b19; asc       ;;  2: len 7; hex 14000140340110; asc    @4  ;;  3: len 4; hex 80003039; asc   09;;  4: SQL NULL; 86Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  87. 87. InnoDB Information Schema tables INNODB_TRX INNODB_LOCKS INNODB_LOCK_WAITS 87Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  88. 88. InnoDB Information Schema tables mysql> SELECT * FROM INNODB_LOCK_WAITS; +­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+ |requesting_trx_id|requested_lock_id|blocking_trx_id|blocking_lock_id| +­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+ | 1B1F            | 1B1F:0:81967:6  | 1B19          | 1B19:0:81967:6 | +­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+ 1 row in set (0.00 sec) 88Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  89. 89. InnoDB Information Schema tables mysql> select trx_mysql_thread_id, trx_id from innodb_trx; +­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­+ | trx_mysql_thread_id | trx_id   | +­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­+ |                  31 | 1B1F     | |                  32 | 1B19     | +­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­+ 2 rows in set (0.00 sec) 89Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  90. 90. MySQL Access Privilege System 90Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Picture Here
  91. 91. MySQL Access Privilege System Overview No roles by default, limited user limits All records are in the mysql database (schema) Pluggable authentication since version 5.5 Connections ● TCP/IP with login-password ● Socket (Unix) ● Named pipe (Windows) 91Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  92. 92. MySQL Access Privilege System How to handle connection issues SELECT user, host FROM mysql.user Most descriptive host first, then wildcard Socket connection by default on Unix 92Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  93. 93. MySQL Access Privilege System Sort order mysql> select user, host from mysql.user order by user desc, host  desc; +­­­­­­+­­­­­­­­­­­­+ | user | host       | +­­­­­­+­­­­­­­­­­­­+ | root | localhost  | | root | delly      | | root | ::1        | | root | 127.0.0.1  | | foo  | %          | |      | localhost  | +­­­­­­+­­­­­­­­­­­­+ 6 rows in set (0.00 sec) 93Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  94. 94. MySQL Access Privilege System Wrong access SHOW GRANTS [FOR user@host] Grant tables ● mysql.db ● mysql.tables_priv ● mysql.columns_priv ● mysql.procs_priv ● mysql.proxies_priv SELECT USER(), CURRENT_USER()  94Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  95. 95. MySQL Access Privilege System Grants mysql> show grants; +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | Grants for root@localhost                                                | +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION      | | GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION             | +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 2 rows in set (0.02 sec) 95Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  96. 96. MySQL Access Privilege System Grants mysql> show grants for foo@'%';; +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | Grants for foo@%                                      | +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | GRANT USAGE ON *.* TO 'foo'@'%'                       | | GRANT ALL PRIVILEGES ON `test`.* TO 'foo'@'%'         | +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 2 rows in set (0.00 sec) 96Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  97. 97. THANK YOU! https://twitter.com/#!/svetsmirnova https://blogs.oracle.com/svetasmirnova/ 97Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Picture Here
  98. 98. Graphic Section Divider 98Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  99. 99. The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 99Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×