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

求助:Artifactory无法连接至MySQL主机故障排查

Troubleshooting Artifactory-MySQL Connection Failures in Docker

It looks like your Artifactory container is stuck at "Preparing to run Artifactory..." because it can’t establish a connection to your MySQL host. Let’s walk through the most common fixes based on your command and setup:

1. Fix the Typo in Your DB_PASSWORD Variable

First, I spotted a small but critical typo: your DB_PASSWORD value is my_passowrd (extra 'o'). Correct this to my_password and restart the container—even tiny typos like this will block authentication.

2. Validate Your JDBC URL Format

Your DB_URL uses & instead of the standard & for separating URL parameters. JDBC strings require & directly, not the HTML entity escape. Update your URL to:

jdbc:mysql://my_host_ip:3306/some_db?characterEncoding=UTF-8&elideSetAutoCommits=true

This ensures the database driver parses the parameters correctly.

3. Check MySQL Host Accessibility

Since you’re using --net=host, the container shares your host’s network stack, but we still need to confirm MySQL is reachable:

  • From your host machine, run mysql -h my_host_ip -u my_db_user -p and enter your password. If this fails, your MySQL server isn’t accepting connections from that IP.
  • Open your MySQL config file (usually my.cnf or my.ini) and check the bind-address setting. It should be set to 0.0.0.0 to allow connections from external IPs (not just 127.0.0.1). Restart MySQL after making changes.
  • Ensure your firewall (on the MySQL host) allows incoming traffic on port 3306.

4. Confirm Connector Compatibility

You’re using mysql-connector-java-5.1.46.jar—this version is incompatible with MySQL 8.0+ because it doesn’t support the new caching_sha2_password authentication plugin:

  • If your MySQL server is 8.x, replace the connector with a newer version (e.g., 8.0.33) and update the mount path accordingly.
  • Verify the connector is properly mounted in the container:
    docker exec -it artifactory-host-mysql ls /opt/jfrog/artifactory/tomcat/lib/
    
    Make sure the connector jar appears in the list.

5. Check Database Existence and User Permissions

  • Ensure the some_db database exists on your MySQL server. Run this in the MySQL shell:
    SHOW DATABASES;
    
    If it doesn’t exist, create it with CREATE DATABASE some_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;.
  • Grant full permissions to your user for the database:
    GRANT ALL PRIVILEGES ON some_db.* TO 'my_db_user'@'%' IDENTIFIED BY 'my_password';
    FLUSH PRIVILEGES;
    
    The % allows connections from any IP—you can restrict it to your host IP if needed.

6. Inspect Container Logs for Detailed Errors

The "Preparing to run Artifactory..." message doesn’t show the root cause. Get the full logs with:

docker logs artifactory-host-mysql

Look for lines containing "ERROR" or "Connection refused"—these will tell you exactly what’s failing (e.g., authentication denied, unknown database, or network issues).

Once you’ve addressed these steps, stop and restart the container with the corrected command. If you still run into issues, share the relevant log lines and we can dig deeper.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 06:58:12