Now that we've installed MySQL, let's take a look at MySQL Workbench. MySQL Workbench is a graphical tool for working with MySQL.
What is MySQL Workbench?
MySQL Workbench is a graphical tool for working with MySQL. It's similar to SQL Server Management Studio, which is the main administration console for SQL Server.
MySQL Workbench allows you to program and run queries against your database (eg, create databases, create tables, insert/update & select data, etc). It also allows you to create user accounts, export/import data, monitor client connections, and more.
Download MySQL Workbench
First step to using MySQL Workbench is to make sure it's installed. If it is installed, it's likely to be located where your other applications are located (eg, Program Files on Windows, Applications on a Mac). Also check inside the MySQL folder. If you installed MySQL on a Windows machine using MySQL Installer it's likely that you also installed MySQL Workbench at the same time.
If Workbench isn't installed on your system, you can download it and install it for free. This should only take a few minutes.
First step is to download MySQL Workbench from the MySQL website.
Install MySQL Workbench
Extract the Installer Package
That's it — it's installed!
If you are installing on to Windows or Linux, the steps will be different. See installing MySQL Workbench from the MySQL website if you need help in getting it installed.
Run MySQL Workbench
Now that we've installed it, let's run it.
Open MySQL Workbench
You can open MySQL Workbench just as you would open any other application.
On the Mac we can do it by clicking on the MySQLWorkbench.app icon in the Applications folder.
The Main Workbench
How to Execute a Query?
When working with MySQL, you'll spend a large portion of your time executing queries and other SQL statements and commands.
There are a several ways to execute a query. Choose which method you feel comfortable with. First, you must enter the query into the Query tab. Then once you've done that, you can run it.
- You can run a query by clicking the Run icon. The Run icon looks like this:
- Alternatively, you could click the icon next to it to execute the statement under the keyboard cursor.
- You can also run a query by selecting Query | Execute (All or Selection) (or one of the alternative options).
- You can also run a query by using the keyboard shortcuts as presented next to each option under the Query menu. For example, on a Mac you could use Shift | Command | Enter to Execute (All or Selection).
We'll be running an SQL command next when we create a database so that will give you a chance to practice it :)
Whenever you connect to MySQL, your login credentials are used to determine what access you have. For example, you might be allowed to do some things (like select data) but not others (like delete data or drop a database).
Many users could connect to the same MySQL server and each user could be assigned a different level of access. Generally someone with administrative access privileges will create user accounts with the appropriate access privileges for that user. The administrator can pretty much do anything they need (or want) on the MySQL server.
This tutorial assumes that you have administrative privileges, or at least a privilege that allows you to create, drop, alter databases and their objects, as well as insert, select, update, and delete data within the database.