0

it's my first time using DataGrip trying to connect to MySQL in a Ubuntu 18.04 server.

I've added a new user to MySQL. When I try to connect to MySQL using the command MySQL -u user -p works.

But on DataGrip, I've created an ssh tunnel and it's making the connection without any problems.

But when trying to connect to MySQL it gives this error The specified database user/password combination is rejected: [28000][1698] Access denied for user 'user'@'localhost'.

I am sure that the password is correct and in the log file it is showing that it's making the ssh connection, but it gives access denied when connecting to MySQL. If someone could help me, I appreciate it.

Vasilii Chernov
  • 1,169
  • 8
  • 17
  • 1
    Connecting using the `mysql -u -p ` is different than connecting over the network. Although your user might have access to connect locally (I am fairly sure that by default it would use unix sockets rather than the tcp port) that user doesn't have permission to connect over the network. This post should help https://stackoverflow.com/questions/8348506/grant-remote-access-of-mysql-database-from-any-ip-address – Grizzle Jan 21 '21 at 00:38
  • @Grizzle I saw the post, but in this case shouldn't I be able to connect because of the SSH tunnel ? – Henrique Melo Jan 21 '21 at 00:51
  • As I mentioned, when you use the `mysql` command from the cli it's using a unix socket rather than a over tcp. If you run `mysql -h localhost -u -p ` that will use a network socket and you should get the same error. https://dev.mysql.com/doc/refman/5.7/en/mysql-command-options.html – Grizzle Jan 21 '21 at 00:56
  • 1
    It could be your account doesn't have permission to access over `localhost`. Could you run this query and post the result. It will show all the allowed hosts for your user. `Select host from mysql.user where user = 'user'` @HenriqueDotCom – Minh Vương Phan Jan 21 '21 at 09:13

1 Answers1

1

To connect to MySQL server using unix sockets follow an article in DataGrip documentation.

Connection via sockets available in DataGrip since version 2021.1.

toaruScar
  • 401
  • 4
  • 6
Vasilii Chernov
  • 1,169
  • 8
  • 17
  • 1
    Just upgraded 2021.1.2, I can confirm socket connection is there and working, lovely! – Chris Barry Jun 03 '21 at 05:11
  • There's way to connect via ssh and Unix sockets? getting the socket file from the server? – Chris Sum Jul 29 '21 at 16:41
  • @ChrisSum take a look at [Forward local port or socket file to remote socket file](https://serverfault.com/questions/127794/forward-local-port-or-socket-file-to-remote-socket-file) – Vasilii Chernov Dec 30 '21 at 09:29