新建了一个docker-compose.yaml配置,然后启动服务,发现连不上mysql
报错:Access denied for user
解决办法或者注意事项:
- 修正docker-compose.yaml配置
version: "3.9" services: mysql: image: mysql:5.7 container_name: mysql command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --explicit_defaults_for_timestamp=true --lower_case_table_names=1 --max_allowed_packet=128M --sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO" environment: - MYSQL_ROOT_PASSWORD=1234$$56 restart: always ports: - "13306:3306" volumes: - mysql-data:/var/lib/mysql - mysql-conf:/etc/mysql/conf.d adminer: image: adminer container_name: adminer restart: always ports: - 18080:8080 depends_on: - mysql volumes: mysql-data: {} mysql-conf: {}
- 登录mysql容器,env校验参数成功