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

Windows 10 Pro下Docker部署MySQL登录access denied问题求助

Hey there, let's figure out why you're getting that "access denied" error when trying to log into your MySQL container via the Docker dashboard. I've dealt with this exact issue a few times, so here are the most common fixes to walk through:

常见排查与解决步骤

1. Double-check your login credentials

  • When you first spin up the mysql/mysql-server:latest container, Docker generates a random root password automatically. Grab it by checking the container logs:
    docker logs <your-mysql-container-name>
    
    Look for a line like GENERATED ROOT PASSWORD: [random-string] — that's your initial root password.
  • If you set a custom MYSQL_ROOT_PASSWORD in your docker-compose.yml, make sure the password you're entering matches exactly (watch out for typos, case sensitivity, or special characters that might have been escaped).

2. Allow root access from external addresses

  • By default, MySQL's root user might only be allowed to connect from localhost (inside the container). Since the Docker dashboard is connecting from your Windows host, you'll need to update the user's permissions:
    1. First, jump into the container's MySQL shell:
      docker exec -it <your-mysql-container-name> mysql -uroot -p
      
      Enter the correct root password when prompted.
    2. Run these SQL commands to grant external access:
      ALTER USER 'root'@'%' IDENTIFIED BY 'your-root-password';
      FLUSH PRIVILEGES;
      
      The % wildcard allows connections from any IP — if you want to restrict it to your host's IP, replace % with that specific address.

3. Verify port mapping in docker-compose.yml

  • Make sure your compose file maps the container's 3306 port to your Windows host. Here's a quick example of the correct configuration:
    services:
      mysql:
        image: mysql/mysql-server:latest
        ports:
          - "3306:3306"  # Maps host port 3306 to container port 3306
        environment:
          MYSQL_ROOT_PASSWORD: your-sec-password-here
    
  • If the port mapping is missing or incorrect, the Docker dashboard can't reach the MySQL service even if the container is running fine internally.

4. Reset your Docker dashboard connection

  • Sometimes the dashboard saves old or incorrect connection details. Try deleting the existing connection entry, then create a new one with these correct parameters:
    • Host: localhost (or your Windows machine's IP address)
    • Port: The mapped port from your compose file (usually 3306)
    • Username: root (or a custom user you created)
    • Password: The valid password for that user

5. Confirm the container is actually healthy

  • Even if it looks like the container is running, double-check its status and logs for hidden issues:
    docker ps
    
    Make sure the container's status shows Up (not restarting or exited). If there are restarts, check the latest logs for clues:
    docker logs --tail 50 <your-mysql-container-name>
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.11 08:25:45