大网数据广告活动
服务器运维问答

Why can't I connect to MariaDB with Navicat through SSH tunnel?

· 52CE 我爱测

I've always used Navicat on windows to manage my MySQL/Percona instances. A few days ago I bought a new server and have installed MariaDB 10.3.9. I can connect to it fine when I'm in a putty session SSHd into the box. mysql -u ro…

问题原文

原帖链接 · Codemonkey · CC BY-SA 4.0

I've always used Navicat on windows to manage my MySQL/Percona instances.

A few days ago I bought a new server and have installed MariaDB 10.3.9.

I can connect to it fine when I'm in a putty session SSHd into the box. mysql -u root -p brings it up perfectly.

For some reason though, Navicat throws the error access denied for user 'root'@'::1' (using password: YES)

Navicat settings are the same that I've always used before:

Host Name: localhost Port: 3306 Mysql username: root Mysql password: [root's mysql password]

Use SSH tunnel: yes IP address: [my server's ip] SSH username: [my name] SSH password: [my ssh password]

I'm not sure why it'd work over SSH when I manually do it, but not when Navicat does it, even though it's presumably doing largely the same thing. What's the '::1' bit about, does that point to the problem?

Thanks!

已采纳解答

原帖链接 · Michael Hampton · CC BY-SA 4.0

Actually there are three subtly different root users in MySQL. (Which is a real pain, but it's been this way forever and probably won't change...)

MariaDB [(none)]> select Host, User from mysql.user where User = 'root';
+-----------+------+
| Host      | User |
+-----------+------+
| 127.0.0.1 | root |
| ::1       | root |
| localhost | root |
+-----------+------+
3 rows in set (0.06 sec)

The user root with host localhost is only used when connecting using the UNIX socket. The other users are used when connecting via the TCP socket, via IPv4 or IPv6 respectively.

When you do your ssh port forwarding with Navicat, the TCP socket is used, and specifically the IPv6 TCP socket (as IPv6 is preferred over IPv4). So that user is the one being authenticated against.

Most of us deal with this by making sure the password is set the same for all three rows.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-08-29)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。