Loading
Loading
  • Home

  • Productivity

  • App tips

App tips

6 min read

How to connect to a MySQL database

By Cecilia Gillen · June 4, 2024
Hero image with the logo for MySQL

So maybe you've oversold yourself a bit in a job interview. Or maybe you're a dev looking to connect to MySQL to help you build your next application. Either way, connecting to MySQL isn't as challenging as it sounds.

First, a refresher: MySQL is an open source relational database management system. It's what powers popular apps like Facebook, X, Netflix, and Airbnb. Every time users take an action on those sites, a data point is created—and all that data has to live somewhere. MySQL is a popular place for that data to live and for devs to build apps.

There are a lot of options for connecting to a database with MySQL, but some are (unnecessarily) complicated, like dbForge Studio for MySQL, so I'll focus on the more straightforward solutions and how to get started.

In the spirit of transparency, I'm not a developer, but I did consult some dev friends and SMEs as I worked my way through this process.

Table of contents:

  • How to connect to MySQL using command options

  • How to connect to a MySQL database with a GUI

  • How to download MySQL Community Server

  • 8.4.0 LTS vs. 8.0.37: Which version should you use?

  • What do with a MySQL database

How to connect to MySQL using command options

You can connect to MySQL without downloading any additional software using Command Prompt (for Windows) or Terminal (for Mac). It's a fairly straightforward—and speedy—process if you know what you're doing. Or even if you don't. You don't have to brave the black void of the command screen alone: I'll show you exactly what to input below. 

Note: I'll be using a Mac for this example, but it should look very similar in Windows.

  1. Download the MySQL Community Server for your operating system. For more detailed download instructions, click here.

  2. On Mac, open the Terminal by hitting command + space and searching for Terminal. On Windows, select the Start menu and search for cmd.

  3. Paste /usr/local/mysql/bin/mysql -uroot -p into the Terminal on Mac, or C:\Program Files\MySQL\MySQL Server 8.0\bin for Command Line on Windows. Hit enter. 

    Screenshot showing how to connect to a database using command options.
  4. Enter the password you chose when you downloaded the application. Now, before you get unreasonably upset like I did, be warned that your password will not appear as you type it. But once you hit enter, this is the screen that will appear.

    Screenshot showing how to enter your password using command options.
  5. To connect to a specific database, type use [database name]; and hit enter.

    Screenshot showing connected database using command options in Terminal.

And that's it! You can now access and modify data in the community server. Check out tutorials and articles on MySQL and DigitalOcean for more information on how to use MySQL.

How to connect to a MySQL database with a GUI

While the command-line method is the most common way to connect to a MySQL database, MySQL beginners may prefer to utilize graphical user interface (GUI) tools. These visual tools make it easier for new users to find the options they're looking for, though they won't give you quite as much control as Command Line and Terminal do. 

Two popular GUIs you can use to connect to a MySQL database are MySQL Workbench (for Windows and Mac) and Sequel Ace (only for Mac). Below, I've got instructions for both. 

How to connect using MySQL Workbench

MySQL Workbench is a good choice for Windows users who are new to MySQL. It might also be a solid option if you would use its bonus functionalities like designing databases or the visual performance dashboard.

If you want to use MySQL Workbench to connect to a database, follow these steps to download the software.

  1. Navigate to the official MySQL Workbench download page.

  2. Select your operating system.

  3. Select your OS version. 

  4. Click Download next to DMG Archive for Mac or Go to Download Page next to MySQL Installer MSI for Windows.

  5. On the next screen, click No thanks, just start my download.

  6. Follow your computer's guided instructions for downloading.

Once you've downloaded the software, you can use it to connect to MySQL databases with these steps.

  1. Open MySQL Workbench.

  2. Click the + button next to MySQL connections.

  3. In the pop-up window, type in what you'd like to call the connection in Connection Name. Then type in the Hostname, Port, Username, and Password (if there is one) for the database you want to connect to. I'm using Rfam's public database as an example. 

  4. Click Test connection if you're not 100% positive you have the right information. 

  5. You'll get a pop-up box like this if you're successful. Click OK

    Screenshot showing how to test connection in MySQL Workbench.
  6. Click OK again on the previous window. 

  7. You'll now see the connection listed under MySQL Connections. Click on your new connection. 

    Screenshot showing connections in MySQL Workbench.
  8. If your database requires a password, you'll have to enter it before your connection loads. Once you've entered the password, you'll be taken to the database.

How to connect using Sequel Ace

This option is exclusive to Mac. Downloading Sequel Ace is a breeze (and using it is, too). Just navigate to Sequel Ace in the App Store, and click Get.

Now you're set to launch the software and get connected. 

  1. Open Sequel Ace.

  2. Type in what you'd like to call the connection in Name. Then type in the Host, Database, Port, Username, and Password (if there is one) for the database you want to connect to.

    Screenshot showing how to type in connection information into Sequel Ace.
  3. Click Test connection if you're not 100% positive you have the right information. It should say Connection succeeded if you do.

    Screenshot showing how to test a connection in Sequel Ace.
  4. Click Connect. The database will load with the tables of data on the left.

    Screenshot showing connected database in Sequel Ace.

If you have a Mac, you could also install SQLPro to make the process even easier, but it costs $137.

How to download MySQL Community Server

If you're trying to learn how to connect to a MySQL database, chances are you already have the MySQL Community Server downloaded. But if you haven't taken that preliminary step, here's a quick guide to download it and get started. (Note: this process is practically the same for Windows and Mac installation, but I'll cover the minor differences when they come up.)

  1. Navigate to the official MySQL download page.

  2. Choose a MySQL Community Server version (8.4.0 LTS is the latest).

  3. Select your operating system.

  4. For Mac, select your OS version (this step doesn't appear for Windows). If your device has an Apple M1, M2, or M3 processor, choose ARM. If you have an Intel chip, choose the other option ("x" followed by a number). 

  5. Click Download for DMG Archive for Mac or click Go to Download page for MySQL Installer MSI for Windows.

  6. The next screen will ask you if you want to log in or sign up for an Oracle Web Account, but this isn't required to download the app. Click No thanks, just start my download.

  7. Save the password you chose for your MySQL server during the download process—you'll need it later.

  • For Mac users, the destination code for your MySQL folder will be: /usr/local/mysql/bin/mysql -uroot -p.

  • For Windows users, you'll choose the location for MySQL, so your destination code will look slightly different depending on where you save it. If you don't choose a specific location, the default location is: C:\Program Files\MySQL\MySQL Server 8.0\bin.

Now that you've downloaded the Community Server, you can choose one of the methods from earlier in this post to connect to MySQL databases.

8.4.0 LTS vs. 8.0.37: Which version should you use?

There are currently two generally available versions of MySQL Community Server: 8.4.0 LTS and 8.0.37. The former is more up to date than the latter, but both will allow you to connect to a MySQL database using one of the above methods. 

The 8.4.0 LTS (long-term support) version includes all the features from the previous version, 8.3.0 Innovation, while focusing on security and bug fixes. Version 8.0.37 only includes bug fixes, meaning you won't get any of the new features from the Innovation update track.

Per Oracle, Innovation and LTS versions are best for fast-paced development environments that emphasize quicker upgrade cycles. So if stability is critical, you may want to stick to the 8.0.x track, which will continue to receive bug fixes until April 2026. 

What to do with a MySQL database

Now that you've learned how to connect to a MySQL database, you can use it to efficiently store, organize, retrieve, and update data. A MySQL database can store data for all the software your company uses in separate tables (rather than lumping it into one big storehouse).

And by using MySQL with Zapier, you can connect MySQL with all the other apps you use at work, to do things like add new leads or form responses to your database. Learn more about how to automate MySQL, or get started with one of these pre-made workflows.

Save Typeform form entries to a MySQL Database

Save Typeform form entries to a MySQL Database
  • Typeform logo
  • MySQL logo
Typeform + MySQL

Send Slack channel messages for new rows in MySQL (custom query)

Send Slack channel messages for new rows in MySQL (custom query)
  • MySQL logo
  • Slack logo
MySQL + Slack

Send Gmail emails for new rows in My SQL

Send Gmail emails for new rows in My SQL
  • MySQL logo
  • Gmail logo
MySQL + Gmail

Zapier is the leader in workflow automation—integrating with 6,000+ apps from partners like Google, Salesforce, and Microsoft. Use interfaces, data tables, and logic to build secure, automated systems for your business-critical workflows across your organization's technology stack. Learn more.

Or, if you find you need a different database solution, you can create automation-ready databases with Zapier Tables.

Related reading:

  • Collecting complex data? Here's how to automate it with Zapier

  • Automated workflows to help you get the most out of your database

  • Zapier Tables: A better way to store (and use) your data

  • Spreadsheets aren't databases—stop using them like one

  • How to connect Firebase to Google Sheets

This article was originally published in May 2023. The most recent update, with contributions from Dylan Reber, was in May 2024.

Get productivity tips delivered straight to your inbox

We’ll email you 1-3 times per week—and never share your information.

tags
mentioned apps

Related articles

Improve your productivity automatically. Use Zapier to get your apps working together.

Sign up
A Zap with the trigger 'When I get a new lead from Facebook,' and the action 'Notify my team in Slack'