如何通过WordPress Docker Image从Azure App Service连接到MySQL的Azure数据库?
我有一个Azure应用程序服务,使用来自Docker Hub的最新WordPress映像。 Azure应用服务的屏幕截图:
然后在Azure App Service中 - >应用程序设置,我添加了以下键/值对,该对将用于连接mysql的Azure数据库:
- wordpress_db_host
- wordpress_db_name
- wordpress_dpress_dpress_dbasssword
- wordpress_db_db_user
在我的MySQL的Azure数据库中,我启用了公共访问 /允许从任何Azure服务中使用公共访问 /还添加我的客户端IP,此IP范围为0.0.0.0.0.0.0.255.255.255.255。我可以从我的客户端访问它,并创建将由Azure App Service使用的数据库。屏幕截图如下:
在服务器参数中,我还关闭require_secure_transport设置:
最后,我尝试启动该站点,但是它会引发错误“建立数据库连接的错误”,下面的屏幕截图:
我是WordPress / Docker的新手,不知道如何解决此问题。我还审查了一些视频 /文档,但没有看到任何其他配置差异。您能指导我如何解决这个问题吗?非常感谢。
I have an azure app service, using the latest wordpress image from docker hub. The screenshot for the azure app service:
Then in the azure app service -> application setting, I added the following key/value pairs which will be used to connect Azure database for mysql:
- WORDPRESS_DB_HOST
- WORDPRESS_DB_NAME
- WORDPRESS_DB_PASSSWORD
- WORDPRESS_DB_USER
Inside my Azure database for mysql, I have enabled public access / allow public access from any azure service / also add my client ip and this ip range 0.0.0.0 - 255.255.255.255. I can access it from my client and create the database which will be used by azure app service. Screenshot like below:
in server parameters, I also turn off the require_secure_transport setting:
At last, I tried to launch the site, but it throws the error "Error establishing a database connection", screenshot below:
I'm new to wordpress / docker, and don't know how to fix this issue. I also reviewed some videos / docs, and didn't see any other configuration differences. Could you please guide me how to fix this issue? Thanks very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您收到了此错误消息。
这意味着接收到MySQL连接。因此,您知道主机名是正确的,并且云提供商的防火墙设置允许您的WordPress实例与您的MySQL实例交换网络数据。
怎么了?
MySQL的用户名 /帐户名设置具有怪癖。帐户名称看起来像
'ivan'@'localhost'
或'ivan'@'@'%'
(甚至类似'ivan'@'@'192.0。 22.33'
)。其中第一个仅允许从Localhost登录(或通过SSH进行隧道)。第二个允许从
'%'
登录,这意味着任何主机。您需要第二个用于WordPress实例才能访问MySQL。当您从计算机上登录MySQL时,请执行此操作。
您应该看到两行,例如,
当主机丢失时,可能会带有
'%'
的帐户。如果是这样,则意味着您需要创建另一个MySQL帐户,并让其访问您的数据库。这样做。接下来,确保您刚创建的用户帐户(您的WordPress软件将用于连接到MySQL)可以访问您的数据库。
如果您仍然收到错误消息,则可能在
'Ivan'@'%'
帐户上的密码不匹配您在WordPress配置中的内容。您可以将其更改,如果它仍然提供相同的错误消息,则您的云供应商可能需要TLS连接到MySQL。您可能需要就此咨询他们的支持团队。
(这是一个常见的绊脚石设置新的WordPress实例。)
You received this error message.
It means MySQL received, processed, and rejected your WordPress instance's attempt to connect. So you know the hostname is right and your cloud provider's firewall settings allow your WordPress instance to exchange network data with your MySQL instance.
What's wrong?
MySQL's user name / account name setup has a quirk. An account name can look like
'ivan'@'localhost'
or'ivan'@'%'
(or even something like'ivan'@'192.0.22.33'
).The first of those only allows login from localhost (or via tunneling via ssh). The second allows login from
'%'
, meaning any host. You need the second one for your WordPress instance to get access to MySQL.When you're logged in to MySQL from your machine, do this.
You should see two rows, like these
It's possible the account with
'%'
as the host is missing. If so that means you need to create another MySQL account and give it access to your database. Do that like this.Next, make sure the user account you just created -- the one your WordPress software will use to connect to MySQL -- has access to your database.
If you still get the error message, it's possible the password on your
'ivan'@'%'
account doesn't match what you put into your WordPress configuration. You can change it withIf it still gives the same error message, it's possible that your cloud vendor requires TLS to connect to MySQL. You may want to consult their support team about that.
(This is a common stumbling block setting up new WordPress instances.)
好的,只是要保持并使事情清晰。 IPS都可以连接到DB,但是您实际上有权在DB中读取/写入日期吗?
即这可能是一个许可/特权问题。
我建议对用户特权进行双重检查,并确定谁可以做DB的
最佳问候。 :-)
ok just to keep and make things clear. all IPs can connect to the DB but are you actually authorized to read/write date in the DB?
I.E. this might be a permission/privilege issue.
I suggest double checking user privileges and determine who can do what on your DB
Best Regards. :-)