elkshadow5
elkshadow5

Reputation: 439

How to create or connect to a localhost database in DataGrip?

I previously had issues with MySQL on a Linux boot of my computer, and I realized that JetBrains has an SQL IDE for MacOS that I want to use to work on homework for my Database Systems class. The course is based on MySQL and following the steps here was useless.

I am just trying to create a local database to connect to and run various MySQL scripts for homework, but DataGrip will not let me create a database and connect to it. I am just using the defaults for MySQL (name is @localhost, driver is MySQL ver. 8.0.15 [latest], host localhost, port 3306, user root, password root, database , URL jdbc:mysql://localhost:3306) and every time it says "Connection to @localhost failed. [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up."

My IDE looks exactly like the picture here and the test connection button gives me the same error as above. I tried the accepted solution here but that seemed to do nothing and I still can't connect to my localhost database. I can't run CREATE DATABASE my_database as explained here because I get the error java.net.ConnectException: Connection refused (Connection refused).

What am I missing or doing wrong? I'm literally just using all of the default settings and nothing is working.

Upvotes: 3

Views: 14464

Answers (2)

javier Cuervas
javier Cuervas

Reputation: 933

In case someone has the same problem i had, make sure the driver for mysql configured in datagrip matches server version. I had a server running mysql 5.7 and the driver for mysql 8, therefore the connection was wrong. After change the driver for MySql 5 i was able to succesfully connect

Upvotes: 1

moscas
moscas

Reputation: 10335

DataGrip is the software which connects to the existing server. It cannot run the MySQL server itself. You need to figure out how to run the local MySQL server, and only after you succeed with this, you'll be able to connect to it via DataGrip.

Upvotes: 8

Related Questions