简体   繁体   English

在Docker容器上运行phinx命令时访问被拒绝

[英]Access denied when running phinx command on Docker container

I am running the official MySQL Docker container for my PHP app. 我正在为我的PHP应用程序运行官方的MySQL Docker容器。 I am using Phinx for migrations. 我正在使用Phinx进行迁移。 The MySQL image seems to work fine as I can connect to it as 'dbuser' (non-root) using MySQL Workbench. MySQL映像似乎运行良好,因为我可以使用MySQL Workbench以“ dbuser”(非root用户)身份连接到它。 I can also connect with Docker exec as well. 我也可以与Docker exec连接。

Problem occurs when I try to run any Phinx command, such as status. 当我尝试运行任何Phinx命令(例如状态)时,都会出现问题。 I'm getting: 我越来越:

[InvalidArgumentException]
There was a problem connecting to the database: SQLSTATE[HY000][1045] Access denied for user 'dbuser'@'localhost' (using password: YES)

My grants on the DB look like: 我在数据库上的赠款如下:

GRANT USAGE ON *.* TO 'dbuser'@'%' IDENTIFIED BY PASSWORD '*8232A1298A49F710DBEE0B330C42EEC825D4190A'
GRANT ALL PRIVILEGES ON `dbuser`.* TO 'app_db'@'%'

My development section of the phinx.yml file looks like: 我的phinx.yml文件的development部分如下所示:

development:
    adapter: mysql
    host: localhost
    name: app_db
    user: dbuser
    pass: '<no-hash-password>'
    port: 3306
    charset: utf8

Any ideas? 有任何想法吗?

Solved it: I had MySQL running on the host as well (different port 3307), so I shut that down. 解决了它:我也在主机上运行了MySQL(不同的端口3307),所以我关闭了它。 I'm now able to run phinx within the container. 我现在可以在容器中运行phinx Looks like it might have been trying to connect to the host server via unix socket, instead of port 3306 on the container. 看起来它可能一直在尝试通过unix套接字而不是容器上的端口3306连接到主机服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM