Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于docker compose 部署MySQL 5.7后,一直提示 :Access denied for user 'root'@'localhost' (using password: NO) #381

Open
wusuobuzai2393 opened this issue Oct 29, 2024 · 1 comment

Comments

@wusuobuzai2393
Copy link

只是修改了密码,MySQL容器进入后本地可以正常登录,但是远程访问报错,my.cnf中添加bind-address=0.0.0.0 和重新给用户授权也不行。

docker-compose.yml MySQL配置:
services:
mysql:
image: mysql:5.7
container_name: mysql-ops
environment:
- MYSQL_DATABASE=opsmanage
- MYSQL_USER=%
- MYSQL_USER="ops"
- MYSQL_PASSWORD="ops123123"
- MYSQL_ROOT_PASSWORD="ops123123"
volumes:
- /data/apps/mysql:/var/lib/mysql
- /data/apps/mysql/my.cnf:/etc/my.cnf
command: ['mysqld', '--sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci', '--bind-address=0.0.0.0']
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
timeout: 20s
retries: 10
restart: always
networks:
- default

MySQL日志:
2024-10-29T08:56:47.224252Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2024-10-29T08:56:47.224253Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2024-10-29T08:56:47.224919Z 0 [Warning] CA certificate ca.pem is self signed.
2024-10-29T08:56:47.224954Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2024-10-29T08:56:47.225224Z 0 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
2024-10-29T08:56:47.225280Z 0 [Note] - '0.0.0.0' resolves to '0.0.0.0';
2024-10-29T08:56:47.225303Z 0 [Note] Server socket created on IP: '0.0.0.0'.
2024-10-29T08:56:47.225940Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2024-10-29T08:56:47.233149Z 0 [Note] Event Scheduler: Loaded 0 events
2024-10-29T08:56:47.233335Z 0 [Note] mysqld: ready for connections.
Version: '5.7.44' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
2024-10-29T08:57:16.488658Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2024-10-29T08:57:16.776737Z 3 [Note] Access denied for user 'root'@'ops_web.docker_default' (using password: NO)
2024-10-29T08:57:46.573563Z 16 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2024-10-29T08:58:16.622975Z 28 [Note] Access denied for user 'root'@'localhost' (using password: NO)

@welliamcao
Copy link
Owner

你初始化之后修改了MySQL密码吗?这样要修改配置文件里面的MySQL密码

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants