How to install MySQL on Windows for app development
A relational database underpins every modern enterprise architecture. As such, programmers need a local database installation for development, experimentation and testing before code is sent into production.
The MySQL Community Server -- as the open source database is formally known -- is an excellent choice for local development because it is a popular, lightweight, open source database with an abundance of users to provide online support through various forums and discussion boards. The community server can also be packaged with a variety of developer tools which can help simplify database management and administration.
Let's explore how easy it is to install MySQL on Windows and examine the following three important MySQL developer tools:
- The MySQL Workbench
- The MySQL Shell
- Connector/J -- the MySQL JDBC driver
How to install MySQL on Windows with custom features
Developers can download the database and all of the associated MySQL tools as a single product install from the MySQL development website. Don't choose each product individually. Instead, use the 420 MB MySQL Installer for Windows. The latter option will allow a developer to install MySQL on Windows with all the developer tools at the same time as part of a custom installation.
As you install MySQL on Windows, the program will automatically choose C:\Program Files as the default directory. However, I prefer to install it into an alternate folder where the binaries are easier to access. Also, it's a best practice to avoid using folder names that contain spaces as it can cause runtime errors in software scripts that are tedious to troubleshoot. For my local installation, I changed the default MySQL install directory to C:\_mysql.
MySQL JDBC driver installation
After the MySQL install wizard completes, open the file system explorer and confirm that the MySQL JDBC drivers were saved under the Connector/J subfolder. This JAR file will contain the following two JDBC drivers:
- mysql.cj.jdbc.Driver (new development)
- mysql.jdbc.Driver (for legacy JPA, Hibernate and JDBC development support)
The cj driver is recommended for all new JDBC development, while the legacy driver can be used for backward compatibility with older systems.
The MySQL Workbench developer tool
A developer can verify that the MySQL install was successful by trying to connect to the database server with the Workbench tool. If the MySQL Workbench can connect on port 3306 and it's possible to browse the tables under the default schema named sys, then the database is running locally, and you have successfully installed MySQL on Windows.
If connectivity with the MySQL tool is successful, you know that the database is indeed running locally, which means the MySQL install on Windows was successful. And with the JDBC drivers at the ready, you're all set to boot up your favorite IDE and start database driven application development and testing.