Set up MySQL service
We support MariaDB version 10.0, which includes reimplemented features from MySQL 5.6 and 5.7.
To access the MariaDB database directly, open an SSH tunnel and use the following command:
1 mysql -h database.internal -u user
You can use the following instructions for service setup on Magento Commerce Cloud Pro Integration environments and Starter environments, including
master branch. You must submit a support ticket to configure the service on Pro Production and Staging environments. See Services.
Set up multiple database users
Optionally, you can set up multiple databases as well as multiple users with different permissions.
An endpoint is a user who has privileges you specify. By default, there is one endpoint named
mysql that has administrator access to all defined databases. To set up multiple databases and users, you must specify multiple endpoints.
You cannot use multiple databases with Magento Commerce at this time. You can create multiple endpoints to restrict access to the
To specify user access, use the
endpoints nested array. Each endpoint can have access to one or more schemas (databases), and can have different levels of permission on each.
The valid permission levels are:
ro: Only SELECT queries are allowed.
rw: SELECT queries as well as INSERT/UPDATE/DELETE queries are allowed.
admin: All queries are allowed, including DDL queries (CREATE TABLE, DROP TABLE, and so on).
If no endpoints are defined, a single endpoint named
admin access to the
main database. For example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 mysqldb: type: mysql:10.0 disk: 2048 configuration: schemas: - main endpoints: admin: default_schema: main privileges: main: admin reporter: privileges: main: ro importer: privileges: main: rw
In the preceding example, the endpoint (that is, user)
ro privileges to the
main database and endpoint
rw access to the
main database. This means that:
adminuser has full control of the database.
repoteruser has SELECT privileges only.
importeruser has SELECT, INSERT, UPDATE, and DELETE privileges.
Add MySQL in services.yaml and .magento.app.yaml
To enable MySQL, add the following code with your installed version and allocated disk space in MB to
1 2 3 mysql: type: mysql:10.0 disk: 2048
To configure the relationships for the environment variable, set a relationship in your
.magento.app.yaml in the Git branch. For example:
1 2 relationships: database: "mydatabase:mysql"
Merge and deploy the code to set the configurations for Redis. For information on how these changes affect your environments, see
- If you configure one MySQL user, you cannot use the
DEFINERaccess control mechanism for stored procedures and views.
- MySQL errors such as
PDO Exception 'MySQL server has gone awayare usually the result of exhausting your existing disk space. Be sure you have sufficient space allocated to the service in
Verify environment-related relationships
We use the Magento Commerce Cloud environment variable
$MAGENTO_CLOUD_RELATIONSHIPS, a JSON object, to retrieve environment-related relationships.
To verify information used for configurations and settings:
Use SSH to log in to the remote environment.
pretty-printof all relationships for services and configuration data for that environment.
php -r 'print_r(json_decode(base64_decode($_ENV["MAGENTO_CLOUD_RELATIONSHIPS"])));'