You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用IntelliJ Database Navigator插件连接MySQL服务器?连接失败求助

Hey there! Let's figure out why you can't connect your self-hosted MySQL server to IntelliJ's Database Navigator—even when your username and password are correct. Since I can't view the screenshot directly, I’ll cover the most common culprits and fixes that usually resolve this kind of connection issue.

Troubleshooting Steps for IntelliJ Database Navigator & Self-Hosted MySQL

1. Check if MySQL allows remote connections

By default, MySQL is set to only accept connections from localhost (the same machine it’s running on). If your app and MySQL are on different machines (or even if you’re testing locally but using a non-loopback IP), this will block you:

  • Open your MySQL config file (it’s usually my.cnf on Linux/macOS, my.ini on Windows)
  • Look for the bind-address line and change it to 0.0.0.0 (to allow all IPs) or your specific client IP address
  • Restart the MySQL service:
    • Linux: sudo systemctl restart mysql
    • Windows: Open the Services app, find MySQL, and click Restart
  • Next, grant your user permission to connect from your client machine. Run this in the MySQL shell:
    GRANT ALL PRIVILEGES ON *.* TO 'your_username'@'%' IDENTIFIED BY 'your_password';
    FLUSH PRIVILEGES;
    
    Replace your_username and your_password with your actual credentials. The % lets the user connect from any IP—for better security, replace it with your client’s exact IP later.

2. Verify your firewall isn’t blocking port 3306

MySQL uses port 3306 by default, and firewalls often block this port by default:

  • Linux: Check if the port is open with sudo ufw status. If not, allow it with sudo ufw allow 3306/tcp
  • Windows: Open Windows Defender Firewall > Advanced Settings > Inbound Rules, then create a new rule to allow TCP traffic on port 3306
  • macOS: Go to System Settings > Network > Firewall > Options, and add MySQL to the list of allowed apps

3. Double-check IntelliJ’s connection settings

Even small mistakes here can cause failures:

  • Host: Make sure you’re using the correct IP of your MySQL server (don’t use localhost if it’s a remote server)
  • Port: Confirm it’s set to 3306 (or your custom port if you changed it during setup)
  • Authentication Method: Try switching between Standard and MySQL Native Password—newer MySQL versions use caching_sha2_password which can have compatibility issues with older JDBC drivers
  • Database: If you’re targeting a specific database, ensure it exists in MySQL; you can leave this blank to connect to the server first and browse databases later

4. Update the JDBC driver in IntelliJ

Outdated drivers are a common source of connection problems. When setting up your connection in IntelliJ, look for a prompt that says "Download" next to the driver version. Click it to install the latest MySQL JDBC driver—this often fixes compatibility gaps.

Quick Test to Narrow Things Down

First, try connecting to MySQL using the command line to rule out server-side issues:

mysql -h your_server_ip -u your_username -p

If this works, the problem is definitely with IntelliJ’s settings. If it fails, focus on fixing MySQL’s remote access or firewall rules first.


内容的提问来源于stack exchange,提问作者Salim

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 09:46:46