devcontainers-contrib / features

🐳 Extra add-in features for Devcontainers and GitHub Codespaces
MIT License
214 stars 108 forks source link

Where are default MYSQL credentials? #594

Open sovetski opened 2 months ago

sovetski commented 2 months ago

Requested Feature

Hi,

My devcontainer.json is:

{
  "image": "mcr.microsoft.com/devcontainers/base:ubuntu",
  "features": {
    "ghcr.io/shyim/devcontainers-features/php:0": {
    "version": 8.1
    },
    "ghcr.io/devcontainers-contrib/features/mysql-homebrew:1": {},
  },
}

The problem here with MYSQL, is that I don't know what are default credentials for MYSQL, to be able to connect to the database.

Thanks in advance

vanduc2514 commented 2 months ago

I think devcontainer features in general only address the installation of additional packages / tools to the base image. So, like other devcontainer features, you can only select different version or different way of install a package. The setting of default credential for MySQL seems like out of scope of devcontainer features. However, to achieve this, you can try to use postCreateCommand of devcontainer.

{
  "image": "mcr.microsoft.com/devcontainers/base:ubuntu",
  "features": {
    "ghcr.io/shyim/devcontainers-features/php:0": {
    "version": 8.1
    },
    "ghcr.io/devcontainers-contrib/features/mysql-homebrew:1": {},
  },
 "postCreateCommand": "mysqladmin -u root password 123456"
}

where the user name is root and password is 123456. This command run only once, when the devcontainer is created