mysql would you like transactions
TRANSCRIPT
-
7/27/2019 MySQL Would You Like Transactions
1/79
www.brianhitchcock.net
MySQL
Would You Like Some TransactionsWith That Table?
-
7/27/2019 MySQL Would You Like Transactions
2/79
www.brianhitchcock.netOct 29, 2009 Page 2
Slides Are Available
-
7/27/2019 MySQL Would You Like Transactions
3/79
www.brianhitchcock.netOct 29, 2009 Page 3
What Is MySQL?
Most popular open source RDBMSOpen source means 'free'
Really? No cost at all?
Widely usedSabre airline reservationsGoogle
LinkedInWhat does Oracle DBA need to know?
Many differences...
-
7/27/2019 MySQL Would You Like Transactions
4/79
www.brianhitchcock.netOct 29, 2009 Page 4
Why Should I Care?
I'm an Oracle DBAMySQL means nothing to meIt isn't a 'real' RDBMS
Why should I learn about MySQL?MySQL is being used by real businessesCan't hurt your employability
Many jobs expect DBA to know multiple RDBMSWhy not learn one that is widely used?
And it's free you can download and install right now!
-
7/27/2019 MySQL Would You Like Transactions
5/79
www.brianhitchcock.netOct 29, 2009 Page 5
Oracle DBA Perspective
What will we look at?InstallingStart/stopHow database/tables storedBackupsTransactions
Storage engines
-
7/27/2019 MySQL Would You Like Transactions
6/79
www.brianhitchcock.netOct 29, 2009 Page 6
My Message
Compare MySQL to OracleNot to be critical of MySQLNot to praise Oracle
Make Oracle DBAs awareHow much we assume about RDBMSBecause Oracle does things a certain way
MySQL is very different
Assuming it is like Oracle can cause serious problemsDoes your business understand the differences?
The cost of being 'free'?
-
7/27/2019 MySQL Would You Like Transactions
7/79
www.brianhitchcock.netOct 29, 2009 Page 7
MySQL Versions
MySQL EnterpriseHave to buy support
MySQL Community EditionThe 'free' version
MySQL Community Edition Preview Release Available for downloadReady for prime time?
Oracle doesn't offer 12g for trial download...
-
7/27/2019 MySQL Would You Like Transactions
8/79
www.brianhitchcock.netOct 29, 2009 Page 8
MySQL Versions
-
7/27/2019 MySQL Would You Like Transactions
9/79
www.brianhitchcock.netOct 29, 2009 Page 9
MySQL Where Did It Come From?
Used to store web site logsTransactions
What's that?
If we lose some recordsSo what?
Supported by an individualDo your own thing
RecoveryNot to worry, plenty more web logs every day
-
7/27/2019 MySQL Would You Like Transactions
10/79
www.brianhitchcock.netOct 29, 2009 Page 10
Some Differences MySQL/Oracle
OracleDatabaseSchema
a group of database objects
Database user Maps to a database schemaMySQL
Server
DatabasesGroup of database objectsUsers don't map to database
-
7/27/2019 MySQL Would You Like Transactions
11/79
www.brianhitchcock.netOct 29, 2009 Page 11
Some Differences MySQL/Oracle
Storage enginesTransaction supportPerformance
Hot backupBinary logging and recoveryTable locking
CorruptionMisc.
-
7/27/2019 MySQL Would You Like Transactions
12/79
www.brianhitchcock.netOct 29, 2009 Page 12
Storage Engines
MySQL gives you a choiceOracle, all transactional all the time (OATATT)
MySQL storage engines
MyISAM (IBM, Indexed Sequential Access Method)Very fast read
InnoDBTransactional, like Oracle
Separate software, owned by OracleMany others
See next chart
-
7/27/2019 MySQL Would You Like Transactions
13/79
www.brianhitchcock.netOct 29, 2009 Page 13
Storage Engines
-
7/27/2019 MySQL Would You Like Transactions
14/79
www.brianhitchcock.netOct 29, 2009 Page 14
InnoDB Storage Engine
Imagine mixingMyISAM, InnoDB tables in a statementWhat does 'transactional' mean?
What does recovery mean?
-
7/27/2019 MySQL Would You Like Transactions
15/79
www.brianhitchcock.netOct 29, 2009 Page 15
CSV Storage Engine
CSV storage engineStores data in text filesUsing comma-separated format
-
7/27/2019 MySQL Would You Like Transactions
16/79
www.brianhitchcock.netOct 29, 2009 Page 16
Blackhole Storage Engine
My favorite
This is where we store all the data relating to the Raiders andtheir 'Commitment to Excellence'
-
7/27/2019 MySQL Would You Like Transactions
17/79
www.brianhitchcock.netOct 29, 2009 Page 17
Yeah, But...
No problemI'll just make all the tables InnoDB
Cool, but
MySQL catalog (system?) tables are MyISAMCan't change themTable storage engine can be changed at any time
Privileged usersNo one should do this, but...stuff happens
Create table syntaxSupports overriding default storage engine
-
7/27/2019 MySQL Would You Like Transactions
18/79
www.brianhitchcock.netOct 29, 2009 Page 18
Transaction Support
MyISAMDefault table typeTable type of system databases
Does not support transactionsExample
Writing to MyISAM tables and server crashesWho know what was and wasn't written to tablesNo recovery
-
7/27/2019 MySQL Would You Like Transactions
19/79
www.brianhitchcock.netOct 29, 2009 Page 19
Performance
Many large MySQL servers in usePerformance must be goodor good enough for 'free'
Optimizer Different storage enginesHow to optimize statement that has
MyISAM tablesInnoDB tables
Does it support all storage engines you are using?
-
7/27/2019 MySQL Would You Like Transactions
20/79
www.brianhitchcock.netOct 29, 2009 Page 20
Hot BackupMySQL does not have this
Backup option #1Shutdown server, copy all files, startup server
Backup option #2
Lock all tablesDump all data to a dump file
Dump file is set of SQL to recreate databaseVery slow to recover
Backup option #3Buy hot backup software product
Not free
-
7/27/2019 MySQL Would You Like Transactions
21/79
www.brianhitchcock.netOct 29, 2009 Page 21
Binary Logging and Recovery
MySQLDefault, no loggingYou can configure binary logging
Three formatsStatement-basedRow-basedMixed
Binary log filenames have formatbinlog.000001, binlog.000002, etc.You must apply them in correct order
-
7/27/2019 MySQL Would You Like Transactions
22/79
www.brianhitchcock.netOct 29, 2009 Page 22
MySQL Binary Logs
MySQL does not have any way of knowingwhen replaying the binary logs whichstatements need to be executed and which arealready committed.
Oracle DBA doesn't worry about thisOracle checks and tells you which archived redo logis needed nextOracle won't allow archived redo logs to be appliedout of order
-
7/27/2019 MySQL Would You Like Transactions
23/79
www.brianhitchcock.netOct 29, 2009 Page 23
Binary Logging Formats
-
7/27/2019 MySQL Would You Like Transactions
24/79
www.brianhitchcock.netOct 29, 2009 Page 24
Binary Log Issues
-
7/27/2019 MySQL Would You Like Transactions
25/79
www.brianhitchcock.netOct 29, 2009 Page 25
Table Locking
MyISAM storage engineDoes not support row level locking
Table locks
Performance?InnoDB storage engine
Supports row level locking
-
7/27/2019 MySQL Would You Like Transactions
26/79
www.brianhitchcock.netOct 29, 2009 Page 26
Corruption
OracleI have rarely seen any casesBut all tables support transactions
MySQLWhat does it mean to rollback
When different storage engines involvedSome support transactions, some don'tSome tables will be rolled back
Others won't
Is this corruption?
-
7/27/2019 MySQL Would You Like Transactions
27/79
www.brianhitchcock.netOct 29, 2009 Page 27
MySQL Corruption Issues
Good readDiscusses corruption issues in MySQL enginesI'm not saying this happens often
But you need to be aware of these issues Another difference from Oracle
Different storage engines, different corruption mechanisms
http://www.mysqlperformanceblog.com/2006/07/30/mysql-crash-recovery/
-
7/27/2019 MySQL Would You Like Transactions
28/79
www.brianhitchcock.netOct 29, 2009 Page 28
MySQL Issues
MiscReferential Integrity
Some storage engines support
TriggersRow-level, not statement-level
DirectloadNot supported
Parallel QueryNot supported
-
7/27/2019 MySQL Would You Like Transactions
29/79
www.brianhitchcock.netOct 29, 2009 Page 29
MySQL Issues
White Paper Compares MySQL to PostgreSQL
PostgreSQL, another open source RDBMS
More like Oracle than MySQLDiscusses issues with MySQL
I'm not endorsing PostgreSQLBut the whitepaper is very good
GooglePostgreSQL vs. MySQL A Comparison of EnterpriseSuitability
-
7/27/2019 MySQL Would You Like Transactions
30/79
www.brianhitchcock.netOct 29, 2009 Page 30
MySQL Table Storage
MyISAMEach table has three files
.frm Data dictonary information
.MYD table data.MYI table indexes
InnoDBData and indexes in a tablespaces
Made up of one or more datafilesSound familiar?
-
7/27/2019 MySQL Would You Like Transactions
31/79
www.brianhitchcock.netOct 29, 2009 Page 31
Documentation Online
-
7/27/2019 MySQL Would You Like Transactions
32/79
www.brianhitchcock.netOct 29, 2009 Page 32
Documentation Online
-
7/27/2019 MySQL Would You Like Transactions
33/79
www.brianhitchcock.netOct 29, 2009 Page 33
Documentation Online
-
7/27/2019 MySQL Would You Like Transactions
34/79
www.brianhitchcock.netOct 29, 2009 Page 34
Talk Is Cheap
A little less conversation A little more action
Download and install MySQL to your laptop now
Slides show the stepsWindows
You will have a fully functional MySQL server
Start learning right now
-
7/27/2019 MySQL Would You Like Transactions
35/79
www.brianhitchcock.netOct 29, 2009 Page 35
Install MySQL Windows
Windows Vista6.0 Service Pack 1Screenshots shown
Windows XPProfessional Version 5.1Same steps
Very minor differences in what you see
-
7/27/2019 MySQL Would You Like Transactions
36/79
www.brianhitchcock.netOct 29, 2009 Page 36
Downloads?
-
7/27/2019 MySQL Would You Like Transactions
37/79
www.brianhitchcock.netOct 29, 2009 Page 37
Downloads?
-
7/27/2019 MySQL Would You Like Transactions
38/79
www.brianhitchcock.netOct 29, 2009 Page 38
Enterprise Version
-
7/27/2019 MySQL Would You Like Transactions
39/79
www.brianhitchcock.netOct 29, 2009 Page 39
Community Version
-
7/27/2019 MySQL Would You Like Transactions
40/79
www.brianhitchcock.netOct 29, 2009 Page 40
Windows Downloads
-
7/27/2019 MySQL Would You Like Transactions
41/79
www.brianhitchcock.netOct 29, 2009 Page 41
Windows Installation
-
7/27/2019 MySQL Would You Like Transactions
42/79
www.brianhitchcock.netOct 29, 2009 Page 42
Windows Installation
-
7/27/2019 MySQL Would You Like Transactions
43/79
www.brianhitchcock.netOct 29, 2009 Page 43
Windows Installation
d ll
-
7/27/2019 MySQL Would You Like Transactions
44/79
www.brianhitchcock.netOct 29, 2009 Page 44
Windows Installation
i d ll i
-
7/27/2019 MySQL Would You Like Transactions
45/79
www.brianhitchcock.netOct 29, 2009 Page 45
Windows Installation
Wi d I ll i
-
7/27/2019 MySQL Would You Like Transactions
46/79
www.brianhitchcock.netOct 29, 2009 Page 46
Windows Installation
Wi d I ll i
-
7/27/2019 MySQL Would You Like Transactions
47/79
www.brianhitchcock.netOct 29, 2009 Page 47
Windows Installation
Wi d I t ll ti
-
7/27/2019 MySQL Would You Like Transactions
48/79
www.brianhitchcock.netOct 29, 2009 Page 48
Windows Installation
Wi d I t ll ti
-
7/27/2019 MySQL Would You Like Transactions
49/79
www.brianhitchcock.netOct 29, 2009 Page 49
Windows Installation
Wi d I t ll ti
-
7/27/2019 MySQL Would You Like Transactions
50/79
www.brianhitchcock.netOct 29, 2009 Page 50
Windows Installation
Uncheck
Windows Installation
-
7/27/2019 MySQL Would You Like Transactions
51/79
www.brianhitchcock.netOct 29, 2009 Page 51
Windows Installation
Windows Installation
-
7/27/2019 MySQL Would You Like Transactions
52/79
www.brianhitchcock.netOct 29, 2009 Page 52
Windows Installation
Check
Windows Installation
-
7/27/2019 MySQL Would You Like Transactions
53/79
www.brianhitchcock.netOct 29, 2009 Page 53
Windows Installation
Windows Installation
-
7/27/2019 MySQL Would You Like Transactions
54/79
www.brianhitchcock.netOct 29, 2009 Page 54
Windows Installation
mysql
Windows Installation
-
7/27/2019 MySQL Would You Like Transactions
55/79
www.brianhitchcock.netOct 29, 2009 Page 55
Windows Installation
Accessing MySQL Windows
-
7/27/2019 MySQL Would You Like Transactions
56/79
www.brianhitchcock.netOct 29, 2009 Page 56
Accessing MySQL Windows
Click StartProgramsMySQLMySQL Server 5.1MySQL Command Line Client
Right-clickSend to
Desktop (Create Shortcut)
Double-click desktop iconMySQL Command Line Client
Accessing MySQL Windows
-
7/27/2019 MySQL Would You Like Transactions
57/79
www.brianhitchcock.netOct 29, 2009 Page 57
Accessing MySQL Windows
mysql
Shortcut created at installation
mysql client utility
-
7/27/2019 MySQL Would You Like Transactions
58/79
www.brianhitchcock.netOct 29, 2009 Page 58
mysql client utility
Similar to SQL*Plus
Now What?
-
7/27/2019 MySQL Would You Like Transactions
59/79
www.brianhitchcock.netOct 29, 2009 Page 59
Now What?Stop, start MySQL server
What databases are availableshow databases;
Set default databaseuse
What tables are in the databaseshow tables;
Windows Vista
-
7/27/2019 MySQL Would You Like Transactions
60/79
www.brianhitchcock.netOct 29, 2009 Page 60
Windows Vista
Stop/StartServices
StartSettingsControl PanelSystem and Maintenance
Administrative ToolsServices
Scroll down to MySQL, highlightUpper left, options for Stop, Pause, RestartIf MySQL is down, option to Start
Windows XP
-
7/27/2019 MySQL Would You Like Transactions
61/79
www.brianhitchcock.netOct 29, 2009 Page 61
Windows XPStop/Start
Command linenet stop mysql, net start mysql
ServicesStartControl Panel
Administrative ToolsServices
Services window
Scroll down to MySQL, highlightUpper left, options for Stop, Pause, RestartIf MySQL is down, option to Start
-
7/27/2019 MySQL Would You Like Transactions
62/79
www.brianhitchcock.netOct 29, 2009 Page 62
-
7/27/2019 MySQL Would You Like Transactions
63/79
www.brianhitchcock.netOct 29, 2009 Page 63
System Databases
-
7/27/2019 MySQL Would You Like Transactions
64/79
www.brianhitchcock.netOct 29, 2009 Page 64
y
INFORMATION_SCHEMACatalog database
MYSQL database
User and privilege informationTEST
For you to play in...
These databases are created at installation
MySQL Server Configuration
-
7/27/2019 MySQL Would You Like Transactions
65/79
www.brianhitchcock.netOct 29, 2009 Page 65
y Q gControlled by 'option' file(s)
Similar to Oracle pfile or spfileSHOW VARIABLES
See current values
Standard location(s)Search order
One of the most common problemsPersons don't know where these files areMake changes that don't take affectCan't find the file or files
Option File(s)
-
7/27/2019 MySQL Would You Like Transactions
66/79
www.brianhitchcock.netOct 29, 2009 Page 66
p ( )MySQL searches multiple locations
Uses most recent value of each parameter How to know all files being scanned by MySQL?
mysql help
Note: dash dash help
Option File
-
7/27/2019 MySQL Would You Like Transactions
67/79
www.brianhitchcock.netOct 29, 2009 Page 67
p
Option File
-
7/27/2019 MySQL Would You Like Transactions
68/79
www.brianhitchcock.netOct 29, 2009 Page 68
p
Option File
-
7/27/2019 MySQL Would You Like Transactions
69/79
www.brianhitchcock.netOct 29, 2009 Page 69
Option File
-
7/27/2019 MySQL Would You Like Transactions
70/79
www.brianhitchcock.netOct 29, 2009 Page 70
Option File
-
7/27/2019 MySQL Would You Like Transactions
71/79
www.brianhitchcock.netOct 29, 2009 Page 71
MySQL Filesystem Layout
-
7/27/2019 MySQL Would You Like Transactions
72/79
www.brianhitchcock.netOct 29, 2009 Page 72
From option file (my.ini)basedir
Where software is stored
datadir Where table data is stored
MySQL basedir
-
7/27/2019 MySQL Would You Like Transactions
73/79
www.brianhitchcock.netOct 29, 2009 Page 73
MySQL basedir/bin
-
7/27/2019 MySQL Would You Like Transactions
74/79
www.brianhitchcock.netOct 29, 2009 Page 74
MySQL datadir
-
7/27/2019 MySQL Would You Like Transactions
75/79
www.brianhitchcock.netOct 29, 2009 Page 75
MySQL Log Files
-
7/27/2019 MySQL Would You Like Transactions
76/79
www.brianhitchcock.netOct 29, 2009 Page 76
General Query Log All client requests
Binary Log
Statements that modify dataSlow Query Log
Statements that take longer than 10 seconds
Error LogServer messages
MySQL Log Files
-
7/27/2019 MySQL Would You Like Transactions
77/79
www.brianhitchcock.netOct 29, 2009 Page 77
Find log file locations
Summary
-
7/27/2019 MySQL Would You Like Transactions
78/79
www.brianhitchcock.netOct 29, 2009 Page 78
MySQL is 'free'May need other products to make it work for you
Hot backup for example
MySQL is widely used
MySQL is very different from OracleDBA tasks and issues will be different
MySQL is not better or worse than OracleJust very different
The End?
-
7/27/2019 MySQL Would You Like Transactions
79/79
www.brianhitchcock.netOct 29, 2009 Page 79
You now have a MySQL server installedNo excuses
Learn it, live it, love it
Update your resumeNext?
Multiple MySQL servers on same machine
Replicationetc.