Skip to content

[28000][1045] Access denied for user 'root'@'xxx.xxx.xxx.xxx' (using password: YES) #1113

@Scxw010516

Description

@Scxw010516

I'm currently encountering a problem.
I'm using the mysql:latest image (which should be 9.3.0), and I'm using the following docker-compose.yml configuration to start my container. At this time, everything is working normally, and my Datagrip can connect properly.
But when I restarted MySQL with docker restart mysql, I encountered the problem [28000][1045] Access denied for user 'root'@'192.168.137.1' (using password: YES). Then, I entered the MySQL container, but I also failed [28000][1045] Access denied for user 'root'@'localhost' (using password: YES).I tried the above steps many times, but I encountered the same problem.
But when I switched to mysql:8.3.0, this problem disappeared.

Here is my docker-compose.yml:

mysql:
    image: mysql:8.3.0
    container_name: mysql
    ports:
      - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: fUt8uxRCj#^TKoH
      TZ: Asia/Shanghai
    volumes:
      - "./mysql/conf:/etc/mysql/conf.d"
      - "./mysql/data:/var/lib/mysql"
      - "./mysql/init:/docker-entrypoint-initdb.d"
    networks:
      network:
        ipv4_address: 177.8.0.18

And my .cnf file:

[client]
default_character_set=utf8mb4
[mysql]
default_character_set=utf8mb4
[mysqld]
server-id = 1
log-bin=mysql-bin
binlog_expire_logs_seconds = 2592000
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'
max_connections=1000
symbolic-links=0
default-time_zone = '+8:00'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions