Tag: how to (page 1 of 3)

How to Export the results of a Query using MySQL Workbench

You can use MySQL Workbench to run a query, then export the results of that query to a file.

To do this:

  1. Run the query
  2. Click Export on the Results Grid menu bar

Continue reading

How to Save a MySQL Query Result to a .CSV File

You can save a query result to a .CSV file by using the SELECT ... INTO OUTFILE statement.

You specify the name/location of the file as well as other options, such as field terminators, line terminators, etc.

Continue reading

How to Create a Relationship in MySQL Workbench

To create a relationship in MySQL Workbench:

  1. Create a database model (either create a new model or reverse engineer an existing database)
  2. Viewing the database model, double click on the first table of the relationship
  3. The bottom pane will open with the table details. Click on the Foreign Keys tab
  4. In the left pane, select the foreign key field and referenced table
  5. In the middle pane, select the foreign column and referenced (primary key) column
  6. In the right pane, set any Update/Delete actions you’d like to occur when a primary key record is updated or deleted

The relationship is now established. Repeat steps 4 to 6 for any other foreign key columns in that table.

Continue reading

How to Reverse Engineer a Database in MySQL Workbench

To reverse engineer a database in MySQL Workbench:

  1. Select Database > Reverse Engineer from the top menu of MySQL Workbench
  2. Set/review parameters for connecting to the DBMS then click Continue
  3. Enter password if required, then click OK
  4. The wizard will connect to the DBMS, fetch a list of databases, and check for any issues. Click Continue
  5. Select the database/s you would like to reverse engineer, then click Continue
  6. The wizard will retrieve all objects from the selected schema/s and check the results. Click Continue
  7. Select the database objects you’d like to have reverse engineered, then click Execute
  8. The wizard will now reverse engineer all selected objects and generate the EER diagram (behind the scenes). Click Continue
  9. A summary is displayed. Click Close

The EER diagram is now displayed on the screen.

Continue reading

How to Stop/Start MySQL using MySQL Workbench

To stop/start MySQL using MySQL Workbench:

  1. Select Server > Startup/Shutdown from the top menu
  2. A tab will open showing whether the server is stopped or started. Click either Stop Server or Start Server as required.

Here are screenshots for the above steps.

Continue reading

How to Create a Database from a Script in MySQL

To create a database from a script in MySQL:

  1. Open a Query tab in MySQL Workbench
  2. Run a CREATE DATABASE or CREATE SCHEMA statement to create the database (example below)

This will create a new database.

Screenshot of SQL script that creates a database in MySQL

Example of an SQL script that creates a database with tables, columns etc. In this case, the script has just run and has created the “Music” database. You can see the tables and their columns open in the left navigation pane.

Continue reading

How to Generate a Script from a Diagram in MySQL Workbench

To generate a script from a diagram in MySQL Workbench:

  1. Select File > Export > Forward Engineer SQL CREATE Script...
  2. Enter a location to save the file (optional) and set options to include on the script (such as DROP statements etc), then click Continue
  3. Exclude any objects by deselecting them, otherwise leave them as is, then click Continue
  4. The script is generated. You can copy it to your clipboard or click Finish to save it to a file

Continue reading

How to Create a New Database Diagram using MySQL Workbench

To create a new database diagram using MySQL Workbench:

  1. Click File > New Model from the menu
  2. Create a new schema by clicking the + icon next to Physical Schemas
  3. Add tables by clicking Add Tables, then add/configure their columns in the bottom pane.
  4. Create relationships and any other configurations by using the various tabs
  5. Create a diagram by clicking Model > Create Diagram from Catalog Objects

The diagram will be created. You can rearrange the tables to a more suitable layout by clicking and dragging.

Continue reading

How to View Status and System Variables in MySQL Workbench using the GUI

To view MySQL status and system variables via MySQL Workbench, click on Status and System Variables under the Management tab in the left navigation pane.

Screenshot of the Status and System Variables option in MySQL Workbench

The “Status and System Variables” option allows you to view a list of all variables for the MySQL connection.

This launches the Status and System Variables screen.

Continue reading

How to Check User Privileges in MySQL Workbench using the GUI

To check user privileges in MySQL Workbench, click Users and Privileges on the Management tab of the left navigation pane:

Screenshot of the Users and Privileges button in MySQL Workbench

Clicking on “Users and Privileges” in the left navigation pane.

This opens the Users and Privileges screen on the Login tab.

Continue reading

Older posts

© 2017 Database.Guide

Theme by Anders NorenUp ↑