Chapter 17

Working with Databases

IN THIS CHAPTER

Bullet Getting the MySQL server ready to go

Bullet Retrieving, adding, modifying, and deleting a record in the MySQL database

Any application worth its salt needs to store its data persistently somewhere. Unless you’re writing a “Hello, World!” application, chances are, your application will deal with data. You need a place to store that data efficiently so you can retrieve it easily the next time you need to access it.

When it comes to database servers, you have lots of choices. Here are some of the popular database servers currently available:

  • IBM Db2
  • Microsoft SQL Server
  • MongoDB
  • MySQL
  • Oracle Database
  • PostgreSQL

Although Go can access any of these database servers, I can’t cover all these products in this chapter, so I focus on MySQL because it’s one of the more popular databases for web-based applications.

In this chapter, I show you how to use Go to store your data in databases. You discover how to set up a MySQL database server, create a database and table, and configure it for use with Go.

Setting Up a MySQL Database Server

MySQL has several paid editions designed for commercial use, but you can use the free version, MySQL Community Server, for both development and commercial use. The free version has all the features that you would ...

Get Go Programming Language For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.