Overview

Appendix E. Installing MySQL and creating a database

This appendix explains how to prepare a local relational database for the book’s later Spring examples, which rely on an external DBMS. It emphasizes that while many database technologies are available, the specific choice does not affect the Java or Spring code used in the lessons, and MySQL is selected mainly because it is free, lightweight, and easy to install.

The setup process begins by installing a DBMS on your computer and then installing a matching client application to manage it. In the book’s walkthrough, that means installing MySQL and MySQL Workbench, using the appropriate installer for your operating system and keeping any credentials created during installation, since they are needed to connect later.

After both tools are installed, you connect the client to the local database server using those credentials, test the connection, and then create a new database from the client interface. Once the database appears in the client’s list, it is ready for use by the Spring application examples in the later chapters.

Figure E.1 Once you open MySQL Workbench, click on the plus icon near the label “MySQL Connections” to add a new connection.
Figure E.2 Give the connection a name and fill in the credentials you configured when installing the DBMS. Then, click on the “Test Connection” button to verify that MySQL Workbench can connect to the database.
Figure E.3 Sometimes MySQL Workbench displays a warning message. This warning won’t affect the way you implement the examples in the book. You can click on the “Continue Anyway” button if such a message is displayed.
Figure E.4 If MySQL Workbench connected to the local DBMS, it displays a “Successfully made the MySQL connection” message in a pop-up dialog.
Figure E.5 In the MySQL Workbench main screen, you can now see the connection you added. The connection is displayed as a gray rectangle, and it has the connection’s name.
Figure E.6 After connecting to the DBMS, you can add a new database by clicking on the toolbar's small cylinder icon.
Figure E.7 Give the database a name. Our examples use “spring quickly.” Click on the Apply button to create the database.
Figure E.8 You need to again confirm the creation of the database. In this screen, you also see the query MySQL Workbench sends to the DBMS to create the new database. Click the Apply button to execute the query and create the new database.
Figure E.9 The new database appears on the left side of the window. If you can see it there, it means you successfully created a new database.

FAQ

Why do I need to create a database before using the examples in chapters 12 through 14?You need a database because those examples use an external DBMS. The Spring app will connect to that database while you build the project, so it must exist before you start implementing those chapters.
Do I have to use MySQL for the book’s examples?No. You can use another relational DBMS if you already prefer one, such as Postgres, Oracle, or MS SQL Server. MySQL is used in the book mainly because it is free, lightweight, and easy to install.
Does it matter which DBMS I choose when learning Java and Spring?Not really. The Java and Spring classes and methods stay the same whether you use MySQL, Oracle, Postgres, or another relational database.
What are the basic steps for creating a database for the examples?The main steps are: install the DBMS, install a client application for that DBMS, connect the client to your local DBMS, and then create the database you want to use.
Where can I download MySQL if I decide to use it?You can download MySQL from the official MySQL downloads page: https://dev.mysql.com/downloads/mysql/ .
What should I do during MySQL installation if I’m asked to create an account?Save the username and password you create during installation. You will need those credentials later when you connect from MySQL Workbench.
What client application is recommended for MySQL in the book?The book recommends MySQL Workbench, which is one of the most commonly used client applications for MySQL.
How do I connect MySQL Workbench to my local DBMS?Open MySQL Workbench, click the plus icon near “MySQL Connections,” then enter a connection name and the credentials from your DBMS installation. After that, test the connection.
What if MySQL Workbench shows a warning message during connection setup?For the purposes of the book’s examples, that warning does not affect anything. You can click “Continue Anyway” if the message appears.
How do I create a new database in MySQL Workbench?After opening your saved connection, click the small cylinder icon in the toolbar, enter a database name, and click Apply. Confirm the creation when prompted. If the database appears in the left panel, it was created successfully.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Spring Start Here, Second Edition ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Spring Start Here, Second Edition ebook for free