MySQL Workbench
MySQL Workbench
Abstract
This manual documents the MySQL Workbench SE version 5.2 and the MySQL Workbench OSS version 5.2. If you have not yet installed MySQL Workbench OSS please download your free copy from the download site. MySQL Workbench OSS is available for Windows, Mac OS X, and Linux.
Document generated on: 2012-05-01 (revision: 30311) For legal information, see the Legal Notice.
Table of Contents
Preface and Legal Notice ................................................................................................................. vii 1. MySQL Workbench Introduction ..................................................................................................... 1 2. MySQL Workbench Editions ........................................................................................................... 3 3. Installing and Launching MySQL Workbench ................................................................................... 5
Hardware Requirements ............................................................................................................. 5 Software Requirements .............................................................................................................. 5 Starting MySQL Workbench ....................................................................................................... 6
Installing MySQL Workbench on Windows .......................................................................... 7 Launching MySQL Workbench on Windows ........................................................................ 7 Uninstalling MySQL Workbench on Windows ...................................................................... 8 Installing MySQL Workbench on Linux ................................................................................ 9 Launching MySQL Workbench on Linux ............................................................................. 9 Uninstalling MySQL Workbench on Linux ............................................................................ 9 Installing MySQL Workbench on Mac OS X ...................................................................... 10 Launching MySQL Workbench on Mac OS X .................................................................... 11 Uninstalling MySQL Workbench on Mac OS X .................................................................. 11
4. Getting Started Tutorial ................................................................................................................ 13
Administering a MySQL Server ................................................................................................. 13 Creating a Model ..................................................................................................................... 25 Adding Data to Your Database ................................................................................................. 31
5. The Home Window ...................................................................................................................... 35
Workbench Central .................................................................................................................. 36 Workspace .............................................................................................................................. 37 Workbench Application Minimum Window Size .......................................................................... 37 Workbench Preferences ........................................................................................................... 37
The General Tab ............................................................................................................. 39 The Administrator Tab ...................................................................................................... 39 The SQL Editor Tab ........................................................................................................ 39 The Model Tab ................................................................................................................ 41 The MySQL Tab .............................................................................................................. 42 The Diagram Tab ............................................................................................................. 42 The Appearance Tab ....................................................................................................... 43
6. SQL Development ........................................................................................................................ 45
Open Connection to Start Querying .......................................................................................... 45 New Connection ...................................................................................................................... 46 Edit Table Data ....................................................................................................................... 46 Edit SQL Script ........................................................................................................................ 46 Manage Connections ............................................................................................................... 46 Manage DB Connections Dialog ............................................................................................... 46
The Password Storage Vault ............................................................................................ 47 Standard TCP/IP Connection ............................................................................................ 48 Local Socket/Pipe Connection .......................................................................................... 49 Standard TCP/IP over SSH Connection ............................................................................ 50
SQL Editor .............................................................................................................................. 50
Main Menu ...................................................................................................................... 51 Toolbar ............................................................................................................................ 52 SQL Query Panel ............................................................................................................ 53 Main Tabsheets ............................................................................................................... 54 Sidebar ............................................................................................................................ 59
7. Data Modeling ............................................................................................................................. 65
Open an Existing EER Model ................................................................................................... 66
iii
MySQL Workbench
Create New EER Model ........................................................................................................... 66 Create EER Model from Existing Database ............................................................................... 66 Create EER Model from SQL Script ......................................................................................... 66 Model Editor ............................................................................................................................ 67
Modeling Menus .............................................................................................................. 68 The Toolbar ..................................................................................................................... 77 EER Diagrams ................................................................................................................. 78 The Physical Schemata Panel .......................................................................................... 78 The Schema Privileges Panel ........................................................................................... 79 The SQL Scripts Panel .................................................................................................... 80 The Model Notes Panel ................................................................................................... 80 The History Palette .......................................................................................................... 81 The Model Navigator Panel .............................................................................................. 81 The Catalog Tree Palette ................................................................................................. 81 The Layers Palette .......................................................................................................... 82 The Properties Palette ..................................................................................................... 82
EER Diagram Editor ................................................................................................................ 83
The Vertical Toolbar ........................................................................................................ 83
Working with Models ................................................................................................................ 87
Creating Tables ............................................................................................................... 87 Creating Foreign Key Relationships ................................................................................ 101 Creating Views ............................................................................................................... 105 Creating Routines and Routine Groups ........................................................................... 107 Creating Layers ............................................................................................................. 110 Creating Notes ............................................................................................................... 112 Creating Text Objects .................................................................................................... 112 Creating Images ............................................................................................................. 113 Reverse Engineering ...................................................................................................... 114 Forward Engineering ...................................................................................................... 123
Modeling Tutorials .................................................................................................................. 143
Importing a Data Definition SQL Script ............................................................................ 144 Using the Default Schema .............................................................................................. 145 Basic Modeling .............................................................................................................. 147 Documenting the sakilaDatabase ............................................................................... 149
Printing .................................................................................................................................. 151
Printing Options ............................................................................................................. 151
MySQL Workbench Schema Validation Plugins (Commercial Version) ....................................... 151
General Validation .......................................................................................................... 151 MySQL-Specific Validation .............................................................................................. 152
The DBDoc Model Reporting Dialog Window (Commercial Version) .......................................... 153 Customizing DBDoc Model Reporting Templates ..................................................................... 157
Supported Template Markers .......................................................................................... 161 Creating a Custom Template .......................................................................................... 164
8. Server Administration ................................................................................................................. 169
Server Administration ............................................................................................................. 169 New Server Instance .............................................................................................................. 170 Manage Data Import/Export .................................................................................................... 170 Manage Security .................................................................................................................... 170 Manage Server Instances ....................................................................................................... 170 Creating and Managing Server Instances ................................................................................ 170
New Server Instance Wizard .......................................................................................... 170 Manage Server Instances Dialog .................................................................................... 173
Server Administration and Configuration .................................................................................. 175
The Startup Tab ............................................................................................................. 177
iv
MySQL Workbench
The Configuration Tab .................................................................................................... 178 The Accounts Tab .......................................................................................................... 179 The Connections Tab ..................................................................................................... 181 The Variables Tab ......................................................................................................... 182 The Data Dump Tab ...................................................................................................... 183 The Logs Tab ................................................................................................................ 186
9. Extending Workbench ................................................................................................................ 189
GRT and Workbench Data Organization ................................................................................. 189 Modules ................................................................................................................................. 190 Plugins .................................................................................................................................. 191 Adding a GUI to a Plugin Using MForms ................................................................................ 192 The Workbench Scripting Shell ............................................................................................... 193
Exploring the Workbench Scripting Shell ......................................................................... 193 The Shell Window .......................................................................................................... 194 The Globals, Classes, and Modules Tabs ....................................................................... 195
Tutorial: Writing Plugins .......................................................................................................... 195
10. Keyboard Shortcuts .................................................................................................................. 199 11. MySQL Utilities ........................................................................................................................ 203
Introduction ............................................................................................................................ 203
Introduction to MySQL Utilities ........................................................................................ 203 Connection Parameters .................................................................................................. 204 Introduction to extending the MySQL Utilities ................................................................... 205
Commands ............................................................................................................................ 211 mysql.utilities.command.grep — Search Databases for Objects ......................................... 211 mysql.utilities.command.proc — Search Processes on Servers ......................................... 212
Manual Pages ........................................................................................................................ 214
Brief overview of command-line utilities ........................................................................... 214 mut - MySQL Utilities Testing ......................................................................................... 216 mysqldbcompare- Compare Two Databases and Identify Differences ............................. 218 mysqldbcopy- Copy Database Objects Between Servers .............................................. 225 mysqldbexport- Export Object Definitions or Data from a Database .............................. 229 mysqldbimport- Import Object Definitions or Data into a Database ............................... 236 mysqldiff- Identify Differences Among Database Objects ............................................. 239 mysqldiskusage- Show Database Disk Usage ............................................................ 243 mysqlfailover- Automatic replication health monitoring and failover ............................. 246 mysqlindexcheck- Identify Potentially Redundant Table Indexes .................................. 253 mysqlmetagrep- Search Database Object Definitions ................................................... 255 mysqlprocgrep- Search Server Process Lists .............................................................. 259 mysqlreplicate- Set Up and Start Replication Between Two Servers ........................... 262 mysqlrpladmin- Administration utility for MySQL replication ......................................... 265 mysqlrplcheck- Check Replication Prerequisities ........................................................ 273 mysqlrplshow- Show Slaves for Master Server ............................................................ 276 mysqlserverclone- Clone Existing Server to Create New Server ................................. 279 mysqlserverinfo- Display Common Diagnostic Information from a Server .................... 281 mysqluserclone- Clone Existing User to Create New User .......................................... 283
Parsers .................................................................................................................................. 285 mysql.utilities.parser — Parse MySQL Log Files .............................................................. 285
Appendix ............................................................................................................................... 287
MySQL Utilities FAQ ...................................................................................................... 287
A. Third Party Licenses .................................................................................................................. 289
.NET Flat TabControl License ................................................................................................. 290 ANTLR 3.4 License ................................................................................................................ 290 Bitstream Vera License .......................................................................................................... 291 Boost Library License ............................................................................................................. 292