Search code examples
mysqldbeaverssh-tunnel

Can't connect to mySQL with ssh-tunnel, but local connection wokrs well


I'm trying to connect to mySQL with ssh-tunnel but got "Access denied for user 'bitrix0'@'::1' (using password: YES)" I', using DBeaver.

but local connection works well

[root@bitrixc2 ~]# mysql -u bitrix0 -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 23597
Server version: 5.7.39-42 Percona Server (GPL), Release 42, Revision b0a7dc2da2e

Copyright (c) 2009-2022 Percona LLC and/or its affiliates
Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

List of users:

mysql> SELECT user, host FROM mysql.user WHERE user LIKE 'user' OR host LIKE 'localhost';
+--------------------+-----------+
| user               | host      |
+--------------------+-----------+
| SQLAdmin           | localhost |
| bitrix0            | localhost |
| mysql.session      | localhost |
| mysql.sys          | localhost |
| root               | localhost |
+--------------------+-----------+
6 rows in set (0.00 sec)

mysql>

How can I connect with ssh-tunnel? Or may be DBeaver has special connection options? I tryed to make ssh-tunnel with putty and DBeaver. Both variants got the same error.


Solution

  • Problem solved. I created mysql user with 127.0.0.1 host

    #user_name and password was changed in this example
    CREATE USER 'user_user'@'127.0.0.1' IDENTIFIED BY 'secret_password';
    GRANT ALL PRIVILEGES ON * . * TO 'user_user'@'127.0.0.1';