welliamcao / OpsManage

自动化运维平台: 代码及应用部署CI/CD、资产管理CMDB、计划任务管理平台、SQL审核|回滚、任务调度、站内WIKI
GNU General Public License v2.0
3.45k stars 1.61k forks source link

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

Open wusuobuzai2393 opened 2 weeks ago

wusuobuzai2393 commented 2 weeks ago

只是修改了密码,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日志: 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 commented 1 week ago

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