Is it possible to set a password on a MariaDB/MySQL service?

I have an application that throws an error if I don’t give it a password for a MySQL endpoint, but the default configuration for MySQL on Platform.sh has an empty string in the password field of the relationships variable. How can I manually add a password to this service?

0

Comments

1 comment
Date Votes
  • Although it is not possible to manually set a password for a MySQL or MariaDB service, it is possible to cause Platform.sh to provide a generated password for the database endpoint. If you follow the instructions for defining multiple databases, but you only define a single endpoint, that non-default endpoint will still include a generated password.

    For example:

    db:
        type: "mariadb:10.4"
        disk: 512
        configuration:
            schemas:
              - maindb
            endpoints:
                maindb:
                    default_schema: maindb
                    privileges:
                        maindb: admin
    

    In the above example, a database is manually defined almost identically to the default configuration block, but it will expose a generated password in the $PLATFORM_RELATIONSHIPS environment variable. To use these credentials in your application, you might want to use one of our configuration reader libraries.

    0

Please sign in to leave a comment.

 

Didn't find what you were looking for?

New post