首页 > 解决方案 > MediaWiki docker image - mysql connection problem

问题描述

I'm brand new to containers and am trying to set up a MediaWiki on a Synology NAS. The Synology comes with a package for MediaWiki but it is at 1.30 and they haven't updated in a year. I need a newer version so i can use LDAP with latest extensions.

So, i found this step-by-step guide on how to install the containers with docker. I'm trying it with MediaWiki 1.34.0 and it works fine up to the point that we test connection to the mysql database - 5) Input your MySQL container name and its root password.

When i click Continue i get this error: Cannot access the database: :real_connect(): (HY000/2054): The server requested authentication method unknown to the client. Check the host, username and password and try again. If using "localhost" as the database host, try using "127.0.0.1" instead (or vice versa).

It seems to be that the mediawiki container and the mediawiki-mysql containers aren't networked. I'm looking under network and it shows the following, so they should be able to communicate. I can ping a 172.26.0.2 and 172.26.0.3 address but can't figure how to get past step 5) in that go-by.

enter image description here

I've tried everything i can think of. Using older versions of MediaWiki (e.g. 1.31) and mysql but this connection problem is the sticking point each time. I've reached limit of my capabilities here.

标签: dockermediawikisynology

解决方案


It seems to be that the mediawiki container and the mediawiki-mysql containers aren't networked

Would be interesting where this assumption is coming from. From what I read from the error message, your containers can perfectly fine communicate to each other (they should, as they seem to be on the same network, given that the mediawiki-mysql container is also on a bridged network and in the same subnet).

Let's take a look at the interesting part of the error message:

The server requested authentication method unknown to the client

That looks, to me, as a misconfiguration of mysql. I assume you're using the latest version of the mysql docker container, which should be some version of mysql 8. If you now google for this, you'll find plenty of posts even on stackoverflow, like: https://stackoverflow.com/a/53881212/3394281 php mysqli_connect: authentication method unknown to the client [caching_sha2_password]

To fix this with your current dataset, you could change the authentication plugin from socket to password:

  1. Log in as root to mysql
  2. Run this sql command:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

Replace 'password' with your root password. In case your application does not log in to your database with the root user, replace the 'root' user in the above command with the user that your application uses.

Or, if you're using docker-compose or can change the executed command somehow else, you could follow this answer:

Add the following line to the command: --default-authentication-plugin=mysql_native_password


推荐阅读