Set up MySQL service
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.
Accessing the MariaDB database directly requires you to use a SSH to log in to the remote server, and connect to the database with the following credentials:
mysql -h database.internal -u <username>
For Pro, use the db, username, and password from the relationship:
mysql -h<db> -p<number> -u<username> -p<password>
Add the required name, type, and disk value (in MB) to the
1 2 3
mysql: type: mysql:<version> disk: 2048
Configure the relationships in the
relationships: database: "mysql:mysql"
Add, commit, and push your code changes.
git add -A && git commit -m "Enable mysql service" && git push origin <branch-name>
MySQL errors such as
PDO Exception: MySQL server has gone away may be a result of exhausting existing disk space. Verify that you have allocated sufficient disk space to the service in the
Set up multiple database users
Optionally, you can set up multiple databases as well as multiple users with different permissions.
An endpoint is a set of credentials (or users) with specific privileges. 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 define multiple endpoints in the services.yaml file and declare the relationships in the .magento.app.yaml file.
You cannot use multiple databases with Magento Commerce at this time, but you can create multiple endpoints to restrict access to the
Use a nested array to define the endpoints for specific user access. Each endpoint can designate access to one or more schemas (databases) and different levels of permission on each.
The valid permission levels are:
ro: Only SELECT queries are allowed.
rw: SELECT queries and INSERT, UPDATE, and 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 mysql: type: mysql:10.2 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
admin endpoint provides admin-level access to the
main database, the
reporter endpoint provides read-only access, and the
importer endpoint provides read-write access. This means that:
adminuser has full control of the database.
repoteruser has SELECT privileges only.
importeruser has SELECT, INSERT, UPDATE, and DELETE privileges.
You must add the endpoints defined in the above example to the
relationships property of the
.magento.app.yaml file. For example:
1 2 3 4 relationships: database: "mysql:admin" databasereporter: "mysql:reporter" databaseimporter: "mysql:importer"
If you configure one MySQL user, you cannot use the
DEFINER access control mechanism for stored procedures and views.