Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

SomeT's avatar
Level 1

Connecting to MySQL database via Laravel forge in DataGrip?

Connecting to MySQL database via Laravel forge in DataGrip? How do I achieve this? I tried to type in everything at the default settings, e.g. database name = forge and nothing works it always says connection failed.

Specifically on this screen what kind of information should I be putting in considering most stuff is still at default for my setup?

https://gyazo.com/bc0f4aee8fa36ef25bad634491323e87

0 likes
13 replies
Cronix's avatar
Cronix
Best Answer
Level 67

If you're trying to remotely connect to your db that forge set up, you can only do it using ssh keys. This tells how to do it using Navicat and Sequel Pro. It should be similar for DataGrip, which I've never used.

https://forge.besnappy.com/laravel-forge#databases

You'd fill out all of your server details on the page that you have the screenshot on, and on the next tab (ssh) you'd fill out basically the same info (I think), but also point it to your ssh key that you should already have set up in the forge control panel.

1 like
SomeT's avatar
Level 1

Not actually set up an SSH key on forge, lol. Will have to generate one I guess, these confuse me a bit always, do I create the SSH key on the server or my own local computer?

1 like
Cronix's avatar

You generate one on your home computer or whatever you're using locally, and then use the "SSH Keys" tab in the forge control panel for the server you're wanting access on to copy/paste it into to save the key.

Then in DataGrip, you tell it where the key is on your local machine (the one you generated) and it will use that for the connection to the mysql host on forge.

1 like
SomeT's avatar
Level 1

Ah makes sense, many thanks.

1 like
Cronix's avatar

Sure, when you generate the keys, there will be 2. Upload the public key to Forge, and use the private key in DataGrip, or in your ssh client if you want to be able to ssh into the commanline.

1 like
Cronix's avatar

Mine are named differently. Try it without those. If it doesn't work, use the ip of your server and forge as the user.

SomeT's avatar
Level 1

That did not work either, I think overall I am getting closer haha.

Cronix's avatar

I don't know what else I can say. One thing I did need to do is put "localhost" as the host on the general tab, and use the ip on the ssh tab. I only had to do that for Navicat though. Using Sequel Pro I used the ip address for both. Other than that, I haven't used that DataGrip app so don't know how to set it up specifically.

What does doesn't work mean? Does it do anything? Any connection errors?

1 like
SomeT's avatar
Level 1

Specifically I get the error: JSchException: Auth cancel

I just tried what you said regarding localhost and then I get connection refused, tried it in both tabs vice versa kind of thing.

1 like
Cronix's avatar

Are you using a firewall? Is port 3306 allowing your ip in?

1 like

Please or to participate in this conversation.