Question

How to connect MySQL in Workbench?

Hello, I have added my public key to the security menu. I can connect to my droplets via SSH, but I can’t connect MySQL to Workbench. How to connect MySQL to the workbench? Thank you

https://ibb.co/HgKPhjq


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
February 26, 2024

Hey!

If your SSH key is in a newer format not recognized by MySQL Workbench, you may need to convert it to an RSA key in PEM format or ensure you’re using the latest version of MySQL Workbench, as newer versions might have better support for various SSH key formats and authentication methods.

Can you confirm the version of MySQL Workbench that you are using and the SSH key format that you have?

Besides the unsupported authentication error, usually, the setup should be the following:

  1. Open MySQL Workbench and go to “Database” > “Manage Connections”.
  2. Create a New Connection or edit an existing one.
  3. In the connection settings, navigate to the “SSH” tab.
  4. Fill in the SSH connection details:
    • SSH Hostname: Your droplet’s IP address or hostname.
    • SSH Username: The username you use to SSH into your droplet.
    • SSH Key File: Browse and select your private SSH key file. Ensure you’re selecting the private key, not the public key. If your key is in a format not supported by Workbench (e.g., OpenSSH), you may need to convert it to a supported format like PEM.
    • MySQL Hostname: 127.0.0.1 (assuming MySQL is running on the same server as the SSH service).
    • MySQL Server Port: The port your MySQL server is running on, typically 3306.
    • Username and Password: The MySQL username and password.

Let me know how it goes!

Best,

Bobby

KFSys
Site Moderator
Site Moderator badge
February 25, 2024

Heya @hilmihidayat,

By default connections to port 3306 or whatever you are using for MySQL are blocked, adding your public key to your ~/.ssh/auhtorized_keys file won’t help with that.

First SSH to your Droplet, allow your local’s IP address wheter on port 3306 or on the Whole Droplet. For instance, if we want to allow the IP 10.10.10.10 we use the command as,

ufw allow from 10.10.10.10 to any port 3306

Once that is done you should be able to connect to MySQL, using a MySQL user and password

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel