Installing MySQL
Installing MySQL
Shell
Tutorial: Installing MySQL, MySQL Workbench, and MySQL Shell
Topic Details
Overview In this tutorial, you will install the MySQL
database and the client tools MySQL
Workbench and MySQL Shell.
Key Concepts Install MySQL Database
Create a database user to connect to the
database
Create a database connection in MySQL
Workbench
Connect to the database using MySQL
Shell
Difficulty Beginner
Duration Approximately 60 minutes
Notes Students will require access to the
internet to download the installation
files. They will also need appropriate
permissions on their computers to install
the software.
• MySQL Database Server – This tutorial uses the open-source Community edition.
• MySQL Workbench – a GUI tool for executing database queries and managing MySQL
instances.
• MySQL Shell – a command line interface for executing queries and managing MySQL
instances.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
1
Part 1 – Installing MySQL, MySQL Workbench, and MySQL Shell on Windows
Step 1: Download the Software
To download the software, go to this URL: https://dev.mysql.com/downloads/installer/ and
download the full installer.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
2
On the next page, click the ‘No thanks, just start my download’ link and, when prompted, save the
download file.
Once the file download is complete, navigate to where the file was saved and double-click the file to
start the installation process.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
3
Step 3 – Select the Setup Type
Select the ‘Custom’ option on the first screen and click the ‘Next’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
4
Step 4 – Choose Products to Install
On the ‘Select Products’ screen, select the options to install. In the ‘Available Products’ panel, do the
following:
• Under MySQL Servers MySQL Server MySQL Server 8.0, select the most recent
version of MySQL and click the right arrow (1) to move it to the ‘Products to be Installed’
panel.
• Under Applications MySQL Workbench MySQL Workbench 8.0, select the most
recent version of MySQL Workbench and click the right arrow (1) to move it to the ‘Products
to be Installed’ panel.
• Under Applications MySQL Shell MySQL Shell 8.0, select the most recent version of
MySQL Shell and click the right arrow (1) to move it to the ‘Products to be Installed’ panel.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
5
While unlikely, it may be necessary, or preferred, to install MySQL to a path other than the default.
To use an installation path other than the default. Click each item in the right panel (1) and then
click ‘Advanced Options’ (2).
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
6
In the pop-up window, specify the desired installation path. Note that MySQL Server has two paths.
One path is where the software will be installed. The other is where the data files will be saved.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
7
When the three items above have been completed and the ‘Products to be Installed’ contains the
three items, click the ‘Next’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
8
Step 5 – Path Conflicts
The following screen may be seen if MySQL had been installed previously, but the data directories
were not removed. Choose the path to use to install MySQL Server and MySQL Workbench. The
existing paths may be used.
Once the installation path has been provided, click the ‘Next’ button.
If the exiting paths are used, the following message will be seen when you click the ‘Next’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
9
Confirm that the existing paths will be used.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
10
Step 6 – Execute the Installation
On the ‘Installation Screen’, the status for all three products will show ‘Ready to Install’. Click the
‘Execute’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
11
When the status of all three products is ‘Complete’, click the ‘Next’ button to start configuring the
database server.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
12
Step 7 – Product Configuration
On the ‘Product Configuration’ screen, one product should be listed, MySQL Server, with a ‘Ready to
configure’ status. Click the ‘Next’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
13
Step 8 – Configure the Type and Networking Options
Choose the 'Development Computer' Config Type on the ‘Type and Networking’ screen. Leave the
rest of the fields with the default values. Click the ‘Next’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
14
Step 9 – Choose the Authentication Method
Choose the ‘Use Strong Password Encryption for Authentication’ option as the Authentication
Method and click ‘Next’.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
15
Step 10 – Root Password and User Creation
Provide a password for the root user on the ‘Accounts and Roles’ screen. This password should be
strong as this user has full access to any databases on the server. To avoid using the root user for
any development, create a new user by clicking the ‘Add User’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
16
To create a new user, provide a username. In this example, the username is ‘my_user’.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
17
On the ‘Accounts and Roles’ screen, click the ‘Next’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
18
Step 11 – Configure Windows Service Options
Accept all the default values on the ‘Windows Service’ screen and click the ‘Next’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
19
Step 12 – Server File Permissions Options
Accept the default values on the ‘Server File Permissions’ screen and click the ‘Next’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
20
Step 13 – Apply Configuration
Click the ‘Execute’ button on the ‘Apply Configuration’ screen to apply the configuration changes.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
21
When the configuration has been applied, click the ‘Finish’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
22
Back on the ‘Product Configuration’ screen, the status should now be ‘Configuration Complete’.
Click the ‘Next’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
23
Step 14 – Finalize Installation
On the ‘Installation Complete’ screen, keep the boxes checked to start MySQL Workbench and
MySQL Shell after setup. Click the ‘Finish’ button.
After the ‘Finish’ button is clicked, MySQL Workbench will open in a new window and MySQL Shell
will be started in a new command window. Keep these windows open as the connection to the
database will be tested using each of them.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
24
If MySQL Workbench needs to be opened again, press the Windows Key () and in the search box,
type ‘Workbench’. Click on the ‘MySQL Workbench 8.0 CE’ icon.
If MySQL Shell needs to be opened again, press the Windows key () and the ‘R’ key at the same
time. In the ‘Open:’ box, type cmd (1) and then click the ‘OK’ button (2).
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
25
In the window that opens, type mysqlsh (1) and then press’ Enter’. A Welcome message will
appear (2) when MySQL Shell has started.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
26
Step 15 – Confirming User Access with MySQL Shell
Switch to the command window that would have opened to see that you are connected to MySQL
Shell.
\c my_user@localhost
The \c tells MySQL Shell to create a connection to a database. my_user is the username of the user
that was created earlier. The localhost is the domain address of the server.
Provide the password for the user (1) and press ‘Enter’.
There will be a prompt asking if MySQL Shell should save the password for the user. Press ‘y’ and
then enter to save the password.
Once connected, the command window will look similar to the image below.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
27
Step 16 – Configure MySQL Connection in MySQL Workbench
Switch over to the MySQL Workbench window to create a connection to the new server.
In the window that pops up, provide a name for the connection and the user name of the user we
created earlier. Click the ‘Test connection’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
28
When prompted, provide the password for the user and click ‘OK’. Select the checkbox next to ‘Save
password in vault’ to save the password.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
29
The new connection will now be listed under ‘MySQL Connections’ on the main screen. To connect
to the database, click this connection.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
30
Part 2 – Installing MySQL, MySQL Workbench, and MySQL Shell on Mac OS
Step 1 – Download MySQL Server
To download MySQL Server for Mac, go to this URL: https://dev.mysql.com/downloads/mysql/
and choose the correct version for your hardware.
On the next page, click the ‘No thanks, just start my download’ link and, when prompted, save the
download file.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
31
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
32
Step 2 – Start the Installation
Once the file download is complete, navigate to where the file was saved and double-click the file to
start the installation process.
When the installer starts, there may be a prompt asking to allow the installer permission to proceed.
Click the ‘Allow’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
33
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
34
Step 3 – Installer introduction
On the ‘Introduction’ screen, click the ‘Continue’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
35
Step 4 – License Agreement
Read the software license agreement on the license screen and then click the ‘Continue’ button.
After clicking the ‘Continue’ button, a message about agreeing to the software license agreement
appears. Click the ‘Agree’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
36
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
37
Step 5 – Installation Type
On the ‘Installation Type’ screen, there will be information about how much space the install will
need and where the software will be installed. If you want to change the installation location, click
the ‘Change Install Location’ button and choose a new location.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
38
Step 6 – Configuration
Make sure the ‘Use strong password encryption’ option is selected on the configuration screen.
Click the ‘Next’ button.
On the next screen, enter a strong password for the root user. Ensure the ‘Start MySQL Server once
the installation is complete’ check box is selected. Click the ‘Finish’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
39
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
40
Step 7 – Installation Summary
On the ‘Summary’ page, click the ‘Close’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
41
Step 8 – Download MySQL Workbench
To download MySQL Workbench for Mac OS, go to the URL
https://dev.mysql.com/downloads/workbench/ and click the ‘Download’ button.
On the next page, click the ‘No thanks, just start my download’ link and, when prompted, save the
download file.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
42
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
43
Once the file is downloaded, double-click the file and a window similar to the one below will appear.
Click and drag the ‘MySQLWorkbench.app’ icon into the ‘Applications’ folder.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
44
Step 9 – Running MySQL Workbench
To open MySQL Workbench, simultaneously press the command key (⌘) and space to open
Spotlight. When the Spotlight search bar appears, start typing ‘workbench’. Select the
‘MySQLWorkbench.app’ icon.
A warning that MySQLWorkbench.app was downloaded from the Internet appears. Click the ‘Open’
button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
45
Step 10 – Adding a Connection to MySQL
On the Welcome screen, click the plus icon next to the text ‘MySQL Connections’
In the ‘Setup New Connection’ window, give the connection a name, make sure the hostname is
‘127.0.0.1’, and add ‘root’ as the username.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
46
In the ‘Connect to MySQL Server’ window, enter the password specified in Step 6. You can
optionally specify MySQL Workbench to store the password in the keychain. Click the ‘Ok’ button to
test the connection.
A window with the following message will appear if the test is successful.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
47
Click the ‘OK' button on the ‘Setup Connection Screen’.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
48
Step 11 – Connecting the MySQL
Once the connection is created, click the connection box to connect to the installed MySQL server.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
49
Step 12 – Creating a New User
Once the connection is complete, a window similar to the image below will appear. Click the
‘Administration’ tab and then click the ‘Users and Privileges’ link.
The ‘Users and Privileges’ screen will appear in the right panel. Click the ‘Add Account’ button at the
bottom.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
50
In the window that pops up, enter the login name for the new user. Set the ‘Limit Hosts Matching’
value to ‘localhost’. Provide a password. Ensure that it is a ‘strong’ password. When these are
complete, click the ‘Administrative Roles’ tab.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
51
Under the ‘Administrative Roles’ tab, select the checkbox next to ‘DBA’. The remaining checkboxes
should automatically be selected. Click the ‘Apply’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
52
Step 13 – Update Connection Information
After the user has been created, click the ‘x’ in the ‘Local-Root’ (or whatever the connection was
named) to close the current session.
Back on the Welcome Screen, right-click the connection box and click ‘Edit Connection’.
In the connection details window, change the username to the user created in Step 12. Click the
‘Test Connection’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
53
On the ‘Connect to MySQL Server’ window, enter the password for the user created in Step 12. You
can optionally specify MySQL Workbench to store the password in the keychain. Click the ‘Ok’
button to test the connection.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
54
A window with the following message will appear if the test is successful.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
55
Click the ‘OK' button on the ‘Setup Connection Screen’.
On the Welcome screen, the connection will now show the new user.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
56
Step 14 – Download MySQL Shell
To download MySQL Shell for Mac OS, go to the URL https://dev.mysql.com/downloads/shell/ and
download the appropriate package based on your hardware.
On the next page, click the ‘No thanks, just start my download’ link and, when prompted, save the
download file.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
57
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
58
Step 15 – Begin Installing MySQL Shell
Once the file is downloaded, double-click the file to start the installation process. A window like the
one below will open. Double-click the ‘mysql-shell-8.0.x-macosxx-xxxx.pkg’ file.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
59
Step 16 – Introduction
On the ‘Introduction’ screen, click the ‘Continue’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
60
Step 17 – License
Read the Software License Agreement and click the ‘Continue’ button on the' License' screen.
After clicking the ‘Continue’ button, a message about agreeing to the software license agreement
appears. Click the ‘Agree’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
61
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
62
Step 18 – Installation Type
On the ‘Installation Type’ screen, there will be information about how much space the install will
need and where the software will be installed. If you want to change the installation location, click
the ‘Change Install Location’ button and choose a new location.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
63
Step 19 – Installation Summary
On the ‘Summary’ page, click the ‘Close’ button.
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
64
Step 20 – Using MySQL Shell
Open a terminal window and enter the command mysqlsh
After MySQL Shell starts, connect to the MySQL Server using the command:
\c {username}@localhost
When prompted, enter the password for the user (1). After providing the password, a prompt will
appear asking if MySQL Shell should save the password for the user (2).
Copyright © 2023, Oracle and/or its affiliates. Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners
65