Loading
Loading
  • Home

  • Productivity

  • App tips

App tips

5 min read

How to connect to a MySQL database

By Cecilia Gillen · May 9, 2023
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, Twitter, and Netflix. 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 like you 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 other subject matter experts as I worked my way through this process. 

Table of contents:

How to download MySQL Community Server

Before you choose your method for connecting to a MySQL database, you'll need to download the MySQL server. The MySQL community server is what enables your device to connect to MySQL databases. Here's how to download it and get started.

  1. Navigate to the official MySQL download page.

  2. Select your operating system.

    Screenshot showing how to select operating server when downloading MySQL Community Server.
  3. For Mac, select your OS version (this step doesn't appear for Windows). You can find this information in your device's About settings. (Click the Apple icon in the top-left corner of the screen, and select About This Mac. If you see Apple M1 or Apple M2 listed as your processor, choose ARM. If you see Intel, choose the other option: "x" followed by a number. You may need to update your device to a listed compatible version.)

    Screenshot showing how to select Mac OS when downloading MySQL Community Server.
  4. Click Download for DMG Archive for Mac, or click Go to Download Page for MySQL Installer MSI for Windows.

    Screenshot showing how to download MySQL Community Server for Mac.
    Screenshot showing how to download MySQL Community Server for Windows.
  5. 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.

    Screenshot showing how to skip sign up when downloading MySQL Community Server.
  6. Follow your computer's guided instructions for downloading.

  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.

How to connect to MySQL

There are two main ways you can connect to a MySQL database:

  • MySQL beginners may feel more comfortable with graphical user interface (GUI) tools like MySQL Workbench (for Windows and Mac) or Sequel Ace (only for Mac). These visual tools make it easier for new users to find the options they're looking for.

  • If you're more comfortable with MySQL, you can use command options via Command Line (for Windows) or Terminal (for Mac). This option will be faster and give you more control if you know what you're doing. 

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 accessing its 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.

Screenshot showing how to add a connection in MySQL Workbench.

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

Attention Mac users—this is the option for you. 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 connect using command options

This isn't the easiest option for connecting to a MySQL database. I simultaneously felt like I was hacking into some high-security files while also fighting the urge to angrily smash my keyboard like a 14-year-old playing Call of Duty. While it was easier for me to use a GUI tool, you may prefer command options for their flexibility. You don't have to download additional software, and it will be faster if you know what you're doing.

Keep that in mind, and if you hate it, you can always try using MySQL Workbench or Sequel Ace (for Mac users) instead. 

  1. Open the Terminal (for Mac) or Command Line (for Windows) application.

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

    Screenshot showing how to connect to a database using command options.
  3. 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.
  4. To connect to a specific database, type use [database name]; and hit enter.

    Screenshot showing connected database using command options in Terminal.
  5. 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.

Automate MySQL

MySQL is an awesome tool for storing and accessing data. If you really want to make this database work for you, learn how to automate MySQL next. Then you can do things like automatically add form responses to MySQL or send notifications from MySQL to wherever you spend your time. Here are a few examples.

Save Typeform form entries to a MySQL Database

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

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.

Related reading:

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'