Magento 2.1.18 is the final 2.1.x release. After June 2019, Magento 2.1.x will no longer receive security patches, quality fixes, or documentation updates.
To maintain your site's performance, security, and PCI compliance, upgrade to the latest version of Magento.

Connect to the database

There are two ways to connect to the database. Before you begin, you can find the database credentials in the database section of the .docker/config.php file. The examples use the following default credentials:

Filename: .docker/config.php

1
2
3
4
5
6
7
8
9
10
11
return [
    'MAGENTO_CLOUD_RELATIONSHIPS' => base64_encode(json_encode([
        'database' => [
            [
                'host' => 'db',
                'path' => 'magento2',
                'password' => 'magento2',
                'username' => 'magento2',
                'port' => '3306'
            ],
        ],

To connect to the database using Docker commands:

  1. Connect to the CLI container.

    1
    
    docker-compose run deploy bash
    
  2. Connect to the database with a username and password.

    1
    
    mysql --host=db --user=magento2 --password=magento2
    
  3. Verify the version of the database service.

    SELECT VERSION();
    +--------------------------+
    | VERSION()                |
    +--------------------------+
    | 10.0.38-MariaDB-1~xenial |
    +--------------------------+
    

To connect to the database:

  1. Find the port used by the database. The port may change each time you restart Docker.

    1
    
    docker-compose ps
    

    Sample response:

    1
    2
    3
    
              Name                         Command               State               Ports            
    --------------------------------------------------------------------------------------------------
    mc-master_db_1              docker-entrypoint.sh mysqld      Up       0.0.0.0:32769->3306/tcp   
    
  2. Connect to the database with port information from the previous step.

    1
    
    mysql -h127.0.0.1 -p32769 -umagento2 -pmagento2
    
  3. Verify the version of the database service.

    SELECT VERSION();
    +--------------------------+
    | VERSION()                |
    +--------------------------+
    | 10.0.38-MariaDB-1~xenial |
    +--------------------------+
    
Updated