Chapter 5 Administrative Tasks

Table of Contents

5.1 Server Management
5.1.1 MySQL Connection Navigator
5.1.2 MySQL Connections
5.1.3 Server Logs
5.1.4 Service Control
5.1.5 Configuration (options file)
5.2 Users and Privileges
5.3 Server Status
5.4 Status and System Variables
5.5 Database Export and Import
5.6 MySQL Audit Inspector Interface
5.7 MySQL Enterprise Backup Interface
5.7.1 General Requirements
5.7.2 Online Backup
5.7.3 Backup Recovery
5.8 The wbcopytables Tool

MySQL Workbench provides a visual GUI to administer your MySQL environment. The available visual tools help configure your MySQL servers, administer users, perform backup and recovery, inspect audit data, and view database health.

5.1 Server Management

Manage your MySQL instances with a comprehensive view of your MySQL server connections. The visual tree based navigation provides detailed information about server and status variables, including the number of threads, bytes sent and received by clients, buffer allocations size, and more.

5.1.1 MySQL Connection Navigator

The Navigator panel has a Management tab with functionality to monitor and configure your selected MySQL connection.

Note

The Navigator panel also has a Schemas tab for managing databases using your MySQL Connection. For information about the Schemas tab, see Section 7.2.1, “Object Browser and Editor Navigator”.

Figure 5.1 SQL Editor - Navigator Management Tab

SQL Editor - Navigator Management Tab

The Navigator Management tab is separated into the MANAGEMENT, INSTANCE, and PERFORMANCE sections, and the Commercial edition of MySQL Workbench also includes the MYSQL ENTERPRISE section. Each section offers several actions.

5.1.2 MySQL Connections

Manage and create MySQL connections.

5.1.2.1 Creating A New MySQL Connection (Simple)

To add a connection, click the [+] icon to the right of the MySQL Connections title on the Home screen. This opens the Setup New Connection form:

Figure 5.2 Setup New Connection Form

Setup New Connection Form

Important

The Configure Server Management button (bottom left) opens an optional configuration wizard for setting shell commands on the host. For example, commands to start/stop the MySQL instance, or to edit configuration file. For more information, see Section 5.1.2.3.5, “Configure Server Management Wizard”.

Fill out the connection details and optionally click Configure Server Management to execute the Server Management wizard. Click OK to save the connection.

Important

When opening connections, MySQL Workbench automatically sets the client character set to utf8. Manually changing the client character set, such as using SET NAMES ..., may cause MySQL Workbench to not correctly display the characters. For additional information about client character sets, see Connection Character Sets and Collations.

New MySQL connections are added to the Home screen as a tile, and the Section 7.2.1, “Object Browser and Editor Navigator” describes several MySQL Workbench features to monitor and configure each connected MySQL server. A single MySQL Workbench instance can open one or multiple MySQL connections into individual tabs.

For a more detailed overview of this process, see the tutorial titled Section 5.1.2.2, “Creating A New MySQL Connection (Tutorial)”.

5.1.2.2 Creating A New MySQL Connection (Tutorial)

  1. Launch MySQL Workbench. You will be presented with the Home window.

    Figure 5.3 Getting Started Tutorial - Home Window

    Getting Started Tutorial - Home Window

  2. Our example already has two connections created, but let us create a new connection. From the MySQL Workbench Home window, click the [+] icon near the MySQL Connections label. This opens the Setup New Connection wizard.

  3. Define the Connection Name value, which we will set to "MyFirstConnection" in this example.

    Figure 5.4 Getting Started Tutorial - Setup New Connection: MyFirstConnection

    Getting Started Tutorial - Setup New Connection: MyFirstConnection

    The default connection values are for a typical local setup, so check them and enter the appropriate values. If you are unsure, click the Test Connection button to check the connection parameters. Do not press OK.

    Next, optionally click Configure Server Management..., which opens up the Configure Local Management wizard:

  4. Read the Configure Local Management introduction, and press Next to begin defining the new connection parameters.

    Figure 5.5 Getting Started Tutorial - Configure Local Management Introduction

    Getting Started Tutorial - Configure Local Management Introduction

  5. The connection will now be tested. You should see that the connection was successful. If not, click Back and check that you have entered the information correctly.

    Figure 5.6 Getting Started Tutorial - Test Database Connection

    Getting Started Tutorial - Test Database Connection

    Toggle the Show Logs to view additional details about the tested connection, then click Next.

  6. Optionally, you may configure a method for remote management if a Remote Host was specified. Setting these options enables MySQL Workbench to determine the location of configuration files, and the correct start and stop commands to use for the connection.

    SSH login based management and Native Windows remote management types are available. The Operating System and MySQL Installation Type are configured for the SSH login variant.

    We are creating a local MySQL connection in this tutorial, so are skipping the Management and OS and SSH Configuration options, as they are used for configuring a remote MySQL connection.

  7. On Microsoft Windows, select the appropriate MySQL service for the MySQL connection.

    Figure 5.7 Getting Started Tutorial - Windows Management

    Getting Started Tutorial - Windows Management

  8. The wizard will now check its ability to access the start and stop commands, and check access to the MySQL Server configuration file.

    Figure 5.8 Getting Started Tutorial - Test Settings

    Getting Started Tutorial - Test Settings

  9. You now have a chance to review the configuration settings. The information displayed varies slightly depending on platform, connection method, and installation type.

    At the Review Settings prompt, choose "I'd like to review the settings again" to review the settings. Choosing "Continue" closes the "Configure Server Management" dialog.

    Figure 5.9 Getting Started Tutorial - Review Settings

    Getting Started Tutorial - Review Settings

    Check the Change Parameters if you want to check or edit information about the MySQL configuration file. In our example we will check it, and click Next to continue.

  10. Review the MySQL configuration file information. Click the Check buttons to perform the described checks, or optionally change the configuration file path.

    Figure 5.10 Getting Started Tutorial - MySQL Config File

    Getting Started Tutorial - MySQL Config File

  11. Optionally, enter your own commands for starting, stopping, and checking the MySQL connection. Typically the default values are used, which means leaving these optional values blank.

    Figure 5.11 Getting Started Tutorial - Specify Commands

    Getting Started Tutorial - Specify Commands

    Click Finish to close the "Configure Server Management" dialog, which reveals the original Setup New Connection window.

  12. After reviewing the Setup New Connection information, press Test Connection again to make sure it still functions, and then OK to create the new MySQL connection.

    Figure 5.12 Getting Started Tutorial - Setup New Connection

    Getting Started Tutorial - Setup New Connection

  13. Your new MyFirstConnection MySQL connection is now listed on the Home window.

    Figure 5.13 Getting Started Tutorial - Home Window Instance

    Getting Started Tutorial - Home Window Instance

  14. From the Home window, click the new MySQL connection to open the SQL editor for this connection. The SQL editor is the default page, so now select the Server Status from the left Navigator panel to display the connected MySQL server's current status.

    Figure 5.14 Getting Started Tutorial - Server Status

    Getting Started Tutorial - Server Status

  15. Test the other Navigator panel options that relate to your new MySQL connection. Check its status, MySQL logs, and measure its performance statistics from the Dashboard.

    Notice the Management and Schemas tabs on the bottom of the Navigator panel. The Schemas view displays the schemas that are associated with your new MySQL connection. Alternatively, you can merge the Schemas and Management tabs by either clicking the merge icon on the top right of the Navigator panel, or by enabling the Show Management Tools and Schema Tree in a single tab SQL Editor preference.

This concludes the "Creating a MySQL connection" tutorial. For additional information about MySQL connections, see Section 5.1.2, “MySQL Connections”.

5.1.2.3 Manage Server Connections

The Manage Server Connections dialog is another way to manage MySQL connections. This dialog is invoked by either selecting Edit Connection or selecting Database, Manage Connections from the main menu. It can also be invoked from any of the wizards requiring access to a live database.

After the MySQL connection manager is launched, you are presented with the following dialog, with the Connection tab open:

Figure 5.15 Manage Server Connections: Connection Tab

Manage Server Connections: Connection Tab

  • Connection Name: The name used to refer to this connection. This connection can then be selected from a list in other wizards requiring a connection.

  • Connection Method: Method used to connect to the RDBMS.

    After you select a connection method, the fields available in the Parameters, SSL, and Advanced tabs change accordingly. More details about these options and parameters are available below.

Note

The Test Connection button will test the selected MySQL connection and report its connection status. It also reports whether or not SSL is enabled.

For testing remote connections, you might also use ping to check the hostname, or telnet to also check the port. If these fail, then also check the firewall settings on each host, and also that MySQL server is running on the remote host.

5.1.2.3.1 Standard TCP/IP Connection Method

This connection method enables MySQL Workbench to connect to MySQL Server using TCP/IP.

Note

The --skip-networking MySQL server configuration option affects the TCP/IP connection method. If disabled, use named pipes or shared memory (on Windows) or Unix socket files (on Unix).

Parameters tab

  • Hostname: The host name or IP address of the MySQL server.

    Note

    The host name "localhost" might resolve to "127.0.0.1" or "::1" on your host, so note this when checking permissions. For example, if a web application's user only has access to "127.0.0.1" on a host, and a defined connection uses "localhost" that resolves to "::1", this connection may lack the proper permissions to the aforementioned web application. Ping "localhost" on each host to determine where it resolves to.

  • Port: The TCP/IP port on which the MySQL server is listening (the default is 3306).

  • Username: User name to use for the connection.

  • Password: Optional password for the account used. If you enter no password here, you will be prompted to enter the password when MySQL Workbench attempts to establish the connection. MySQL Workbench can store the password in a vault (see Section 5.1.2.3.6, “The Password Storage Vault”).

  • Default Schema: When the connection to the server is established, this is the schema that will be used by default. It becomes the default schema for use in other parts of MySQL Workbench.

Advanced tab

More parameters can be set for the connection by using the Advanced tab.

Figure 5.16 Standard (TCP/IP) Connection: Advanced Tab

Standard (TCP/IP) Connection: Advanced Tab

The Advanced tab includes these check boxes:

  • Use compression protocol: If checked, the communication between the application and the MySQL server will be compressed, which may increase transfer rates. This corresponds to starting a MySQL command-line client with the --compress option. This option is unchecked by default.

  • Use ANSI quotes to quote identifiers: Treat " as an identifier quote character (like the ` quote character) and not as a string quote character. You can still use ` to quote identifiers with this mode enabled. With this option enabled, you cannot use double quotation marks to quote literal strings, because it is interpreted as an identifier. Note: If this option is checked, it overrides the server setting. This option is unchecked by default.

  • Enable Cleartext Authentication Plugin: Send the user password in cleartext. Required for some authentication methods. This option is unchecked by default.

  • Use the old authentication protocol: This option disables Connector/C++'s secure_auth option. This option unchecked by default.

It also includes these options:

SQL_MODE: Override the default SQL_MODE used by the server.

Others: Other options for Connector/C++ as option=value pairs, one per line.

SSL tab

More parameters can be set for the connection by using the SSL tab.

  • SSL: This dropdown provides options related to enabling SSL encryption. Choose No to disable SSL, If available if the client library supports it, or Require to require SSL support for the MySQL connection to succeed. This option defaults to If available.

  • SSL CA File: Path to the Certification Authority file for SSL.

  • SSL CERT File: Path the Certificate file for SSL.

  • SSL Key File: Path to the Key file for SSL.

  • SSL Cipher: Optional list of permissible ciphers to use for SSL encryption.

5.1.2.3.2 Local Socket/Pipe Connection Method

This connection method enables MySQL Workbench to connect to MySQL Server using a socket file (on Unix) or a named pipe (on Windows).

Parameters

The unique field here is Socket/Pipe Path. Enter the name of the socket or pipe here. If the field is left blank, the default socket or pipe name is used. On Unix, the default socket name is /tmp/mysql.sock. On Microsoft Windows, the default pipe name is MySQL.

This option can be seen in the following screenshot.

Figure 5.17 Manage DB Connections - Socket/Pipe Parameters

Manage DB Connections - Socket/Pipe Parameters

Advanced

These are the same options discussed in Section 5.1.2.3.1, “Standard TCP/IP Connection Method”, except there is not the Use compression protocol option.

SSL

These are the same options discussed in Section 5.1.2.3.1, “Standard TCP/IP Connection Method”.

5.1.2.3.3 Standard TCP/IP over SSH Connection Method

This connection method enables MySQL Workbench to connect to MySQL Server using TCP/IP over an SSH connection.

Parameters

In addition to a number of parameters that are in common with Standard TCP/IP connections, this connection method features a number of specialized parameters. These are listed here:

  • SSH Hostname: This is the name of the SSH server. An optional port number can also be provided. For example, localhost:22.

  • SSH Username: This is the name of the SSH user name to connect with.

  • SSH Password: The SSH password. It is recommended that an SSH key file is also used.

  • SSH Key File: A path to the SSH key file.

If a remote host is missing from the system's list of known hosts, a prompt requires you to confirm the host's fingerprint before storing it. If your stored host fingerprint is different than the host's current fingerprint, then an error is generated and you will be required to handle the discrepancy from outside of MySQL Workbench before creating the connection. Prior to MySQL Workbench 6.1.6, the host SSH fingerprint was not saved by MySQL Workbench.

On Linux and OS X, SSH host fingerprints are stored in ~/.ssh/known_hosts. On Microsoft Windows, they are stored in a file created by MySQL Workbench under the user's application data folder (%appdata%), such as C:\Users\[username]\AppData\Roaming\MySQL\Workbench\known_hosts.

The SSH connection options are viewable in the following screenshot:

Figure 5.18 Manage DB Connections - SSH Parameters

Manage DB Connections - SSH Parameters

Advanced

The options here are the same as for the Standard TCP/IP connection. See Section 5.1.2.3.1, “Standard TCP/IP Connection Method”.

SSL

The options here are the same as for the Standard TCP/IP connection. See Section 5.1.2.3.1, “Standard TCP/IP Connection Method”.

5.1.2.3.4 System Profile

The System Profile tab enables you to specify host-specific information. This is achieved primarily through selecting a System Type, along with its corresponding Installation Type. These profile settings contain standard information that is used in managing the host's MySQL instance.

Here are some of the available installation types:

  • FreeBSD, MySQL package or Custom

  • Linux, including several distributions including Fedora, Oracle, RHEL, SLES, Ubuntu, Generic, and Custom

  • OS X, MySQL package or Custom

  • OpenSolaris, MySQL package or Custom

  • Windows, with different installation methods, MySQL versions, and build architectures

After you select the System Type and Installation Type, a number of default parameters will be set that includes: commands used to start and stop MySQL, commands to check the server status, the location of the my.ini or my.cnf configuration file, and on Windows, the Windows Service Name. You may also customize these preset default values.

Figure 5.19 Manage Server Connections: System Profile Tab

Manage Server Connections: System Profile Tab

The Remote Management tab is available when connecting to MySQL remotely.

Figure 5.20 Manage Server Connections: Remote Management Tab

Manage Server Connections: Remote Management Tab

5.1.2.3.5 Configure Server Management Wizard

Clicking the [+] icon from the Home page launches the Setup New Connection wizard. The wizard provides a MySQL connection form to create a new MySQL connection, and includes a Configure Server Management option as a step-by-step approach to creating a new MySQL server connection. This can also be executed later (on remote connections) when from the home page by clicking the top right corner of a MySQL connection tile:

Figure 5.21 Configure Remote Management

Configure Remote Management

Executing this wizard is required to perform tasks requiring shell access to the host. For example, starting/stopping the MySQL instance and editing the configuration file.

The steps presented in the wizard are as follows:

  1. Test DB Connection

  2. Management and OS

  3. SSH Configuration

  4. Windows Management

  5. Test Settings

  6. Review Settings

  7. MySQL Config File

  8. Specify Commands

Test DB Connection

On this page, MySQL Workbench tests your database connection and displays the results. If an error occurs, you are directed to view the logs, which can be done by clicking the Show Logs button.

Management and OS

Used to specify a remote management type and target operating system, which is available when the Host Machine is defined as a remote host.

The SSH login based management option includes configuration entries for the Operating System and MySQL Installation Type.

SSH Configuration

If you specified a Remote Host on the Specify Host Machine page, you will be presented with the Host SSH Connection page, that enables you to use SSH for the connection to the server instance. This facility enables you to create a secure connection to remotely administer and configure the server instance. You must enter the host name and user name of the account that will be used to log in to the server for administration and configuration activities. If you do not enter the optional SSH Key for use with the server, then you will be prompted for the password when the connection is established by MySQL Workbench.

Note

This connection is to enable remote administration and configuration of the MySQL Server itself. It is not the same as the connection used to connect to a server for general database manipulation.

Note

You must use an SSH connection type when managing a remote server if you wish to start or stop the server or edit its configuration file. Other administrative functions do not require an SSH connection.

Windows Management

If a Windows server is used, then the Windows configuration parameters must be set. Windows management requires a user account with the required privileges to query the system status, and to control services. And read/write access to the configuration file is needed to allow editing of the file.

Test Settings

On the next page your settings are tested and the wizard reports back the results after attempting to connect to the server. If an error occurs, you are directed to view the logs, which can be done by clicking the Show Logs button.

MySQL Workbench must know where the MySQL Server configuration file is located to be able to display configuration information. The wizard is able to determine the most likely location of the configuration file, based on the selection made on the Operating System page of the wizard. However, it is possible to test that this information is correct by clicking the Check path and Check section buttons. The wizard then reports whether the configuration file and server configuration section can in fact be accessed. It is also possible to manually enter the location of the configuration file, and the section pertaining to MySQL Server data; these manually entered values should be tested using the buttons provided. Click the Next button to continue.

Review Settings

The modified settings may be reviewed, which also includes the default values. Check the Change Parameters checkbox if the MySQL Config File section will be edited, and then click Next to continue.

MySQL Config File

Allows configuration of the MySQL server version. It also allows the editing and validation of the configuration file path, and validation of the server instance section. Click Next to continue.

Specify Commands

This page enables you to set the commands required to start, stop, and check the status of the running server instance. It is possible to customize the commands if required, but the defaults should be suitable in most cases. The defaults are set based on the options selected in the Operating System page of the wizard. Click Next to continue.

Complete Setup

On this page, you finally assign a name to the server instance. This name is used in various parts of the GUI to enable you to refer to this instance. After setting a suitable name, click Finish to save the instance.

5.1.2.3.6 The Password Storage Vault

The vault provides a convenient secure storage for passwords used to access MySQL servers. By using the vault, you need not enter credentials every time MySQL Workbench attempts to connect to a server.

Note

The hostname is used for storing password information. For example, a local connection might use "localhost", "127.0.0.1", or "::1", but these are stored separately in the password storage vault, even if they all resolve to the same place.

The vault is implemented differently on each platform:

  • Windows: The vault is an encrypted file in the MySQL Workbench data directory. This is where connections.xml and related files are located. The file is encrypted using a Windows API which performs the encryption based on the current user, so only the current user can decrypt it. As a result it is not possible to decrypt the file on any other computer. It is possible to delete the file, in which case all stored passwords are lost, but MySQL Workbench will otherwise perform as expected. You then must re-enter passwords as required.

  • OS X: The vault is implemented using the OS X Secure Keychain. The keychain contents can be viewed using the Keychain Access.app utility.

  • Linux: The vault works by storing passwords using the gnome-keyring daemon, which must be running for password persistence to work. The daemon is automatically started in GNOME desktops, but normally is not in KDE and others. The gnome-keyring daemon can be used for password storage in MySQL Workbench on non-GNOME platforms, but must be started manually.

5.1.2.4 MySQL Fabric Integration

Browse, view status, and connect to any MySQL instance in a Fabric Cluster.

Note

This requires Connector/Python and MySQL Utilities 1.4.3+ installed, including the Python module. This feature also requires MySQL Workbench 6.2+.

To set up a managed Fabric connection, create a new MySQL connection with the new MySQL Fabric Management Node connection method. The connection tiles have a different look:

Figure 5.22 Fabric Connection Group Tile

Fabric Connection Group Tile

Clicking the new fabric group tile shows the managed connections:

Figure 5.23 Fabric Connection Group Tiles

Fabric Connection Group Tiles

5.1.2.5 Client Connections

The client connection browser lists the active and sleeping MySQL client connections, and adds the ability to kill statements and connections, and view additional connection details and attributes.

Note

The connection details viewer requires MySQL 5.6 or greater. Only basic connection information is available for previous versions of MySQL, such as the connection hosts, database, and state.

Figure 5.24 Client Connection Overview

Client Connection Overview

Client Connections and Metadata locks

The Client Connections management window includes a Show Details for connections to MySQL 5.6 and above. These details are separated into three tabs:

  • Details: connection details such as Process ID, Type, User, Host, Instrumented, and additional information.

    Figure 5.25 Client Connections Details

    Client Connection Details

  • Locks: MySQL uses metadata locking to manage access to objects such as tables and triggers. Sometimes a query might be blocked while being manipulated by another connection from another user. The Locks feature utilizes these MySQL metadata locks (MDL) to show the locked connections that are blocked or being waiting on, and shows information about the locks, what they are waiting for, and what they hold.

    Figure 5.26 Metadata Locks Browser

    Metadata Locks Browser

    Note

    The metadata lock information is provided in the performance schema as of MySQL server 5.7.3.

  • Attributes: these are connection attributes such as OS, Client Name, Client Version, and Platform.

    Figure 5.27 Client Connection Attributes

    Client Connection Attributes

5.1.3 Server Logs

The Server Logs page features two subtabs:

Error Log File

General MySQL errors, for more information see The Error Log

Figure 5.28 Navigator Management: Instance: Server Logs: Error Log

Navigator Management: Instance: Server Logs: Error Log

Slow Log File

Slow queries (when available), for more information see The Slow Query Log

Figure 5.29 Navigator Management: Instance: Server Logs: Slow Log

Navigator Management: Instance: Server Logs: Slow Log

5.1.4 Service Control

The Startup / Shutdown functionality includes:

  • Viewing the Startup Message Log

  • Start up and shut down the MySQL instance

  • View the current status of the MySQL instance

Figure 5.30 Navigator Management: Instance: Startup / Shutdown

Navigator Management: Instance: Startup / Shutdown

5.1.5 Configuration (options file)

The Options File editor is used to view and edit the MySQL configuration file (my.ini on Windows, or my.cnf on Linux / OS X) by selecting check boxes and other GUI controls, and then making edits. MySQL Workbench divides the options file into its own groupings as a set of tabs (such as General, Logging, InnoDB, and more). Make an edit and click Apply to commit the changes.

The options file editor has several components:

  • Option file groupings, as divided into convenient tabs by MySQL Workbench

  • A Locate option search field to search your MySQL options configuration file

  • Configuration File path, so you know the configuration file you are editing

  • An options file group selector, to select the option [group] to edit. Because the same option can be defined under multiple groupings, it is important to choose the correct group when making edits. [mysqld] (the MySQL server) is the default and most common group. For additional information about groups, see Using Option Files.

A screenshot with the General tab selected:

Figure 5.31 Navigator Management: Instance: Options File: General

Navigator Management: Instance: Options File: General

5.2 Users and Privileges

A listing of all users and privileges that relate to the MySQL connection. You may also manage (add) user accounts, adjust privileges, and expire passwords.

The Users and Privileges page has several sections:

User Accounts

Lists each user account that is associated to the active MySQL connection.

Login

Login information related to the selected user account.

Figure 5.32 Navigator Management: User And Privileges: Login

Navigator Management: User And Privileges: Login

Account Limits

Define limits for the user account, such as the maximum number of queries, updates, connections, and concurrent connections that an account can execute in one hour.

Figure 5.33 Navigator Management: User And Privileges: Account Limits

Navigator Management: User And Privileges: Account Limits

Administrative Roles

To aid in assigning privileges to MySQL Server users, MySQL Workbench introduces the concept of Administrative Roles. Roles are a quick way of granting a set of privileges to a user, based on the work the user must carry out on the server. It is also possible to assign multiple roles to a user. To assign roles, click the User Account you wish to modify, then click the Administrative Roles tab. Then click the check boxes according to the roles you wish to allocate to the user. After you select a role to a user, you will see the accumulated privileges in the Global Privileges Assigned to User panel. For example, if you select the role BackupAdmin, the privileges granted include EVENT, LOCK TABLES, SELECT, SHOW DATABASES. If you also select the role of ReplicationAdmin, the list of privileges expands to include REPLICATION CLIENT, REPLICATION SLAVE and SUPER.

These roles are available:

  • DBA: Grants all privileges

  • MaintenanceAdmin: Grants privileges to maintain the server

  • ProcessAdmin: Grants privileges to monitor and kill user processes

  • UserAdmin: Grants privileges to create users and reset passwords

  • SecurityAdmin: Grants privileges to manage logins and grant and revoke server privileges

  • MonitorAdmin: Grants privileges to monitor the server

  • DBManager: Grants privileges to manage databases

  • DBDesigner: Grants privileges to create and reverse engineer any database schema

  • ReplicationAdmin: Grants privileges to set up and manage replication

  • BackupAdmin: Grants privileges required to back up databases

  • Custom: Lists other (custom) privileges that are assigned to the user account

The Password Validation Plugin (available as of MySQL Server 5.6.6) is supported in Workbench. For information about what these settings mean, see The Password Validation Plugin.

Figure 5.34 Navigator Management: User And Privileges: Administrative Roles

Navigator Management: User And Privileges: Administrative Roles

Schema Privileges

Additional schema privileges that the account can use. For example, the standard mysqlbackup user has "CREATE TEMPORARY TABLES" on the mysql schema.

Figure 5.35 Navigator Management: User And Privileges: Schema Privileges

Navigator Management: User And Privileges: Schema Privileges

5.3 Server Status

Get an immediate view into the basic health indicators and counters for your MySQL environment. This includes viewing the server's running state (stopped/running), available features, primary server directories, replication state, and security settings for authentication and SSL. Reports also include information and graphs to track memory usage, connections, hit rates, and more.

Figure 5.36 Navigator Management: Server Status

Navigator Management: Server Status

5.4 Status and System Variables

Status and System Variables: Lists all server variables for the MySQL connection. You may also copy all or selected variables to your clipboard.

Figure 5.37 Navigator Management: Status Variables

Navigator Management: Status Variables

Figure 5.38 Navigator Management: Status Variables

Navigator Management: System Variables

Custom Variable Grouping

The status and system variables are each categorized by groups (such as InnoDB or Logging), and you may also create your own custom groups. Right-click on a variable, choose the custom group (or create a new one), and add the variable to the aforementioned group. Your custom groups are listed along with the pre-existing groups.

In the example below, we created a custom group titled "My Variables" and are in the process of adding the Created_tmp_variables variable to it.

Figure 5.39 Navigator Management: Adding A Variable To A Custom Group

Navigator Management: Adding A Variable To A Custom Group

5.5 Database Export and Import

Data Export

This tab allows you to export your MySQL data. Select each schema you want to export, optionally choose specific schema objects/tables from each schema, and generate the export. Configuration options include exporting to a project folder or self-contained SQL file, optionally dump stored routines and events, or skip table data.

Note

Alternatively, use Section 7.1.9, “Export a Result Set” to export a specific result set in the SQL editor to another format such as CSV, JSON, HTML, and XML.

Select the Database objects to export, and configure the related options.

Note

Click Refresh to load the current objects.

Figure 5.40 Navigator Management: Data Export: Object Selection

Navigator Management: Data Export: Object Selection

Optionally open the Advanced Options tab that allows you to refine the export operation. For example, add table locks, use replace instead of insert statements, quote identifiers with backtick characters, and more.

Figure 5.41 Navigator Management: Data Export: Advanced Options

Navigator Management: Data Export: Advanced Options

Click Start Export to begin the export process:

Figure 5.42 Navigator Management: Data Export: Export Progress

Navigator Management: Data Export: Export Progress

This functionality uses the mysqldump command.

Data Import/Restore

Restore exported data from the Data Export operation, or from other exported data from the mysqldump command.

Choose the project folder or self-contained SQL file, choose the schema that the data will be imported to, or choose New to define a new schema.

Figure 5.43 Navigator Management: Data Import: Import From Disk

Navigator Management: Data Import: Import From Disk

Note

You may only select specific data objects (tables) to import if the data export operation used project folders instead of a self-contained SQL file.

Click Start Import to begin the import process:

Figure 5.44 Navigator Management: Data Import: Import Progress

Navigator Management: Data Import: Import Progress

5.6 MySQL Audit Inspector Interface

MySQL Workbench offers a GUI interface to the Audit Inspector.

Note

The Audit Inspector interface was added in MySQL Workbench 6.0.0.

Initially, when you first load the Audit Inspector, you must use MySQL Workbench to cache the audit log for performance reasons. MySQL Workbench will then parse, index, and retrieve values from the encrypted cached file on your local computer. At this stage, you also set a password for the encrypted file that will be used when viewing this file. The initial screen looks similar to:

Figure 5.45 Workbench: Audit Inspector: Initializing

Workbench: Audit Inspector: Initializing

Note

Generating the cache file can take a long time. If you press Abort during the caching process, MySQL Workbench will save the results that were cached at the point you pressed Abort.

After caching an audit log, the Audit Inspector page will display the results:

Figure 5.46 Workbench: Audit Inspector

Workbench: Audit Inspector

The search field offers criteria for narrowing the displayed events, including Show events of type Fetch and Show events of type Query, and defaults to Show all events. Custom filters are also available.

You can Add Files to Cache from the main Audit Inspector page:

Figure 5.47 Workbench: Audit Inspector: Add Files to Cache

Workbench: Audit Inspector: Add Files to Cache

Future uses of the Audit Inspector will require the password that you set during the initial step. The login page:

Figure 5.48 Workbench: Audit Inspector: Unlock

Workbench: Audit Inspector: Unlock

5.7 MySQL Enterprise Backup Interface

MySQL Workbench offers a MySQL Enterprise Backup GUI interface, and supports MySQL Enterprise Backup 3.6.0 and above. It is listed in the Management Navigator tab for a MySQL connection. There are two MySQL Enterprise Backup related sections in the Navigator:

  • Online Backup: Sets a backup profile that defines what should be backed up, where the backup should be stored, and when (the frequency) MySQL should be backed up.

  • Restore: Restores the MySQL server to a specific point in time, typically by restoring a backup that was created by the Online Backup feature in MySQL Workbench.

The MySQL Enterprise Backup configuration is located on the MySQL server, and not locally. This information includes the MySQL Enterprise Backup configuration backup profiles, job scheduling, backup operations, and data. This also means that the backup operations are executed with (or without) MySQL Workbench running.

5.7.1 General Requirements

MySQL Enterprise Backup is a MySQL Enterprise Feature that is separate from MySQL Workbench. For more information about its functionality, see the MySQL Enterprise Backup documentation at http://dev.mysql.com/doc/mysql-enterprise-backup/en. MySQL Workbench provides an interface to MySQL Enterprise Backup, as described in the following documentation. In addition to having MySQL Enterprise Backup installed on your host, the following general requirements also apply:

  • Managing both local and remote MySQL instances is available on Linux and OS X, and managing local MySQL instances is available on Microsoft Windows. Remote management is configured using SSH Remote Management.

  • A MySQL connection with a root user.

  • The MySQL server configuration file path must be set and correct for the MySQL connection.

  • The user running MySQL Workbench must be a sudoer (Linux / OS X) that is able to execute the MySQL Enterprise Backup binary.

  • Additionally, the sudo user must keep the HOME environment variable when executing system commands, which means adding the following to /etc/sudoers:

    
    env_keep +="HOME"
    
    

And the Prerequisites set in the Settings tab are:

  • A path to the MySQL Enterprise Backup executable. MySQL Enterprise Backup is available via eDelivery or My Oracle Support (MOS). MySQL Workbench attempts to locate the MySQL Enterprise Backup executable, so check the path and adjust it accordingly.

  • The path to the Backup Home Directory, where backup profiles and data is stored. This can be created from within Workbench from the Settings tab.

  • The MySQL account for the Backup Process. The available actions depends on the current state of this set up, with options including:

    • Create MEB Account: Available if a backup user does not already exist.

    • Change Password: Available if a backup user does exist.

    • Fix Grants for MEB...: Available if the user's privileges are invalid, which alters the user by adding the RELOAD, SUPER, and REPLICATION CLIENT ON *.* privileges.

Uninstallation notes

  • The MySQL Workbench uninstallation process does not remove the associated MySQL Enterprise Backup backup tasks. To stop the scheduled backups, edit the related "Task Scheduler" entries on Windows, or remove the associated cron jobs on Linux and OS X.

  • The MySQL Workbench uninstallation process does not remove the MySQL Enterprise Backup master related configuration file, the configuration files generated for each defined profile, nor the MySQL backups.

The Settings tab:

Figure 5.49 Workbench: MySQL Enterprise Backup Settings

Workbench: MySQL Enterprise Backup Settings

If any of the requirements are not met, then an error will be generated when attempting to use MySQL Enterprise Backup features.

5.7.2 Online Backup

Sets a backup profile that defines what should be backed up, where the backup should be stored, and when (the frequency) it should be backed up. The main page:

Figure 5.50 Workbench: MySQL Enterprise Backup

Workbench: MySQL Enterprise Backup

The Online Backup page is separated into three sections:

  • Backup Jobs: Used for managing backup jobs for the MySQL server. A backup job (profile) is a configuration file used to store information about what is backed up, where the backup is stored, and optionally when backups will be performed.

    Right-clicking on a Backup Job is an alternative way to access the available actions, such as Configure Job, Delete Job, and Execute Backup. Right-clicking also offers two additional options:

    • Execute Backup to Image File: Saves the backup to a single file, and prompts for the file name.

    • Copy Backup Command to Clipboard: Generates a command for executing the backup, and copies it to your clipboard. You might execute this command in the shell or terminal, which looks similar to: /bin/mysqlbackup --defaults-file="/var/lib/meb/foo.cnf" --show-progress=stdout backup --with-timestamp.

  • Backup Job Details: Displays information about the state of a specific (selected) backup job. It includes information from the Settings page, and information specific to the selected backup.

  • Recent Activity: Historical information about the backup operations performed on the server. View the backup log by right-clicking an entry and choosing View Backup Log

Executing a backup will show a dialog with the progress of the backup operation.

Backup Jobs

Creating a backup job offers several elements. The following information applies to the New Job operation, and Configure Job is used to modify existing jobs.

The Backup Profile Name and its associated Comments field are used to identify the backup job's profile, and this name is listed on the main page.

The New Job scheduling page separates the configuration information into four tabs. The Contents tab defines the schemas and tables to back up, and whether the job is a full or partial backup.

  • Full backup: All schemas and tables are backed up.

  • Partial: Select the schemas and tables (objects) that you want to back up. Choose Select objects to included/excluded to open the table inclusion (and exclusion) options. For additional information about the include, exclude, and Transportable Tablespace options, see the MySQL Enterprise Backup documentation titled Partial Backup and Restore Options.

Figure 5.51 Workbench: MySQL Enterprise Backup Configuration: Contents for Full Backups

Workbench: MySQL Enterprise Backup Configuration: Contents for Full Backups

Figure 5.52 Workbench: MySQL Enterprise Backup Configuration: Contents for Partial Backups

Workbench: MySQL Enterprise Backup Configuration: Contents for Partial Backups

The Options tab includes settings to modify the default behavior of the backup process.

By default, the Backup Storage Directory is stored under a sub-folder using the name of the Backup Profile Name in the MySQL Backup Home Directory setting. Additional options include compression and apply-log, and the option to Skip Unused Pages.

Figure 5.53 Workbench: MySQL Enterprise Backup Configuration: Options

Workbench: MySQL Enterprise Backup Configuration: Options

The Schedule tab optionally sets a backup schedule for both full and incremental backups. The schedule uses the Windows Tasks Scheduler on Microsoft Windows, and a cron job on Linux and OS X. It is scheduled using the operating system user that is scheduling the backup, which is typically the MySQL user.

A full backup is slower than the incremental backup that merges with a full backup. A common scenario is to set a full backup as weekly, and an incremental backup as daily. For additional information about backup performance, see Optimizing Backup Performance.

Figure 5.54 Workbench: MySQL Enterprise Backup Configuration: Schedule

Workbench: MySQL Enterprise Backup Configuration: Schedule

The Advanced tab allows you to pass in additional MySQL Enterprise Backup options.

Note

These additional options are not validated.

To recover backups, see Section 5.7.3, “Backup Recovery”.

5.7.3 Backup Recovery

The Backup Recovery wizard is used to recover MySQL Enterprise Backup backups. For more information about creating MySQL Enterprise Backup backups using MySQL Workbench, see Section 5.7.2, “Online Backup”

The Backup Recovery wizard allows you to restore backups from folders, image files, and backup profiles created by Section 5.7.2, “Online Backup”.

Figure 5.55 Workbench: Backup Recovery: Main page

Workbench: Backup Recovery: Main page

In our example, we will restore a full backup that was created by MySQL Workbench Online Backup. After choosing the "backup (full)" profile that we created earlier, the next page lists each table that will be updated:

Note

We unchecked Show System Schemas the option, which is enabled by default.

Figure 5.56 Workbench: Backup Recovery: Table View

Workbench: Backup Recovery: Table View

Clicking Next > will open the Restore wizard. We then clicked Restore > to execute the restoration process, and toggled the message logs in our example below:

Figure 5.57 Workbench: Backup Recovery: Restore

Workbench: Backup Recovery: Restore

5.8 The wbcopytables Tool

wbcopytables is a command line utility included in MySQL Workbench that allows you to copy table data from a supported source database server to MySQL. It is used by the Workbench Migration wizard to copy data after the schema is migrated and created in the target MySQL server.

wbcopytables can connect to the source database using either ODBC, the Python DBAPI, or the native MySQL client library.

The copy is performed by executing a SELECT statement on the source database, and then INSERT inserts the retrieved rows to the target MySQL server. Several options allow you to control the data that is copied.

Table 5.1 File Location (Default)

Operating SystemLocation
Linux/usr/bin/wbcopytables
OS X/Applications/MySQLWorkbench.app/Contents/MacOS/wbcopytables
WindowsC:\Program Files (x86)\MySQL\MySQL Workbench 6.2\wbcopytables.exe

Connection Parameters

Options for the source connection are:

--odbc-source=ODBC_connection_string: The syntax of the ODBC connection string uses standard ODBC syntax. You can also use a ODBC data source name (DSN).

--mysql-source=MySQL_connection_string: Use for MySQL sources (when doing a MySQL to MySQL migration/copy). It uses the same syntax as the MySQL Utilities:

  • For TCP/IP connections: username[:password]@host:port

  • For local socket connections: username[:password]@::socket_path

You can pass the connection password by using the --source-password option.

For the target connection, the option is: --target=MySQL_connection_string.

You can use the --passwords-from-stdin option to pass a passwords through STDIN. Source and target passwords must be separated by a tab character.

You can use ODBC specific data source options from the source RDBMS to specify the number of rows to fetch at a time for the source SELECT statement.

Table Specification

One or more tables can be specified in the command line for the copy operation. There are two copy types:

  • Full table copy: --table

  • Range copy: --table-range

Both table copy types require a set of common arguments:

  • Source schema: The schema/catalog the table belongs to. If quoting is required, it must be done using the syntax from the source RDBMS. For example, SQL Server uses [square_brackets].

  • Source table: The table to copy. If the source RDBMS uses a schema name in addition to a catalog, both schema and table must be specified here and separated by a dot. For example, [dbo].[mytable].

  • Target schema: The name of the MySQL schema. If quoting is needed, it must use the MySQL backtick syntax. For example, `sakila`.

  • Target table: The name of the MySQL table.

  • Select expression: The list of fields to SELECT. This will be inserted verbatim into the source SELECT statement.

    Caution

    Use caution as this expression is copied directly into the source SELECT statement.

For the select expression, if both the source and target tables have the same fields in the same order, and use compatible types, you can simply pass * here, which will build a query like "SELECT * FROM [dbo].[mytable]". If not, you can specify the fields as you would in the SELECT statement, which are comma (,) separated and with proper escaping/quoting specific to the source RDBMS. You can also specify typecasts and/or data conversions that the source RDBMS supports. For example:

[client_id], [name], [address], AsText([location])

Because each option must be interpreted as a single option by the wbcopytables command, you must perform OS shell specific quoting whenever necessary. Usually, quoting your parameter values with 'single' or "double" quotes is enough. This is in addition to any database specific quoting you use.

Full Table Copy

This performs a full SELECT on the source table, fetches records, and then inserts them into the target table.

There are no additional arguments required.

The --table syntax is as follows:


--table Source_Schema Source_Table Target_Schema Target_Table Select_Expression

Range Copy

This performs a SELECT copy on the source table for the specified range. The table must have a numeric UNIQUE NOT NULL or PRIMARY KEY that is used to create a WHERE expression for the range.

The --table-range syntax is as follows:


--table-range Source_Schema Source_Table Target_Schema Target_Table Select_Expression Source_Key Range_Start Range_End

The generated expression is:


key_column >= range_start AND key_column <= range_end

If you specify -1 for Range_End, then the expression will be:


key_column >= range_start

Other Options

  • --thread-count=Number: If you are copying more than one table, you can use this option to divide the tables across several threads. There is no support for dividing a single table across many threads.

  • --count-only: Only perform a COUNT(*) of the SELECT which would be generated by the --table option that was used. The target schema and table can be omitted in this case.

  • --truncate-target: Execute a TRUNCATE TABLE command on each target table that is copied.

Trigger Handling

Because there is no way to temporarily disable triggers in MySQL and they can affect the copy process, MySQL Workbench will backup and drop all triggers from the target MySQL database before the copy process starts, and then these triggers are restored after the copy finishes. The triggers are backed up in the target schema under a table named wb_tmp_triggers.

  • --disable-triggers-on=Schema_Name: Performs the backup and DROP process for all triggers in the specified schema.

  • --reenable-triggers-on=Schema_Name: Restores triggers previously backed up to the wb_tmp_triggers table.

  • --dont-disable-triggers: Bypass the trigger disabling step.