

#Phpmyadmin docker host mysql install
The change was to rent a single VPS where I had the freedom to install Docker (Docker Swarm) and to host a self-managed database. Previously the three websites had been hosted on a VPS rented from a web hosting provider, using a MySQL server also rented from that provider. What I'll do is to describe a setup similar to what I developed on my server. Setting up a MySQL database server, in Docker, to serve multiple applications There is one user ID per database, and each user ID only has access rights for its database. Once the database is running you can use SQL commands (or PHPMyAdmin) to create additional databases and user ID's. Each application will therefore only have access to its own data, and not to the data of other applications.Ĭonfiguring MySQL to support multiple databases and multiple user ID's is not unique to a Docker deployment.Ĭonfiguring the MySQL Docker container to support multiple databases and multiple user ID's starts with the configuration of a single database and single user ID. To maintain separation between the databases for each application, we define separate user ID's with separate access rights.
#Phpmyadmin docker host mysql how to
What I chose was to work out how to reconfigure a Docker-based MySQL instance to support multiple user ID's and multiple databases. These features are hold-overs from the old days. As a result MySQL is quite capable of storing multiple databases in each server instance, along with multiple user ID's. In the old days we'd configure The Database Server (or servers), storing all data from a long list of applications. But it seemed to me excess overhead to follow that practice, especially since MySQL can easily support multiple databases per server. Using MySQL in the default fashion would result in three containers. Following the best practice that would mean three separate MySQL container instances. The case I faced which inspired this tutorial is that I have three websites, two using Drupal, the third using Wordpress, to deploy to a single VPS. Those environment variables support creating one user ID and one database. The default way to configure the MySQL Docker container is with environment variables.

That means five (or more) containers for the applications, but what about the database server? Do you host five database server containers, each holding a single database? Or do you host a single database server container, holding five databases? Suppose you have five applications to host on a server, each with a separate database? Theoretically the best practice is for each Docker container to serve a single well defined purpose.
