• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Issue Access Mysql from Docker

Phthisicus

New Pleskian
Hi Everyone,

I am trying to connect to the build in MySQL server of Plesk from a Docker container. But i get the following messages:

Could not connect to MySQL database at 10.0.0.100: Access denied for user 'user'@'172.17.0.2'

I am able to login to the MySQL server with that user from other networks even external exept from within the docker container.
The user also has '%' access permissions. I configured the my.cnf of mysql to bind it to :: so every ipv4 and ipv6 adress is able to connect to it.

Is there something i am missing?
 
- Start your MySQL docker from the Command Line as Root

docker run --name=mysql8 -v /path/mysql/datadir:/var/lib/mysql -v /root/mysql8/conf.d:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=RootPassword -p 127.0.0.1:3307:3306 -p 127.0.0.1:33061:33060 "mysql:latest"

- Add the new Database Server to the Plesk via Tools & Settings > Database Servers - Host - 127.0.0.1

- In a Subscription, When you are creating a new database on this new DB server, Select Allow remote connections from any host

This docker is BInd to the Localhost, It will not be accessible externally.
 
Additionally to the above post,

-v for Volume Mapping

-p for Port Mapping

$mysql -h 127.0.0.1 -P 3307 -u user_name -p

Or in your application config file, Eg - 'host' => '127.0.0.1:3307' (Magento 2)
 
A late follow up but hopefully useful to someone..

On Plesk 18, Docker instances can't access the main Plesk DB server locally. Therefore you need to set the DB Host as the server's public IP and ensure all firewalls allow traffic through (both on Plesk and on any network firewall). Furthermore, this was the critical setting that we found needed to be turned on:

Screenshot 2024-07-16 at 21.34.56.png

In our case we're trying to get wiki.js running on docker - but using the standard mariadb server.
 
I might be wrong.. but the docker instant should be able to access the Local DB without above option or the firewall settings. I have done this before.

Did you try both localhost and 127.0.0.1 for the DB settings in your Docker Instant?

By the way which docker is this?
 
Sorry, I didn't mention this in my above post.

Please try this.

Create this docker via command line.

Code:
#docker run --network host --name=Wiki requarks/wiki

Then the settings.

Firefox_Screenshot_2024-07-17T01-25-26.278Z.png


You should be able to connect to local DB without allowing local DB to connect from external connections or the firewall changes.
 
Back
Top