I've tried running Magento's built-in integration testing using MySQL:5.7 docker container on a different port.

php bin/magento dev:tests:run integration

Question is, how can I use a different port?

The following is my dev/tests/integration/etc/install-config-mysql.php

* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.

return [
    'db-host' => 'localhost',
    'db-port' => '33060', // <-- this is not working
    'db-user' => 'root',
    'db-password' => '',
    'db-name' => 'magento_integration_tests',
    'db-prefix' => '',
    'backend-frontname' => 'backend',
    'admin-user' => \Magento\TestFramework\Bootstrap::ADMIN_NAME,
    'admin-password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD,
    'admin-email' => \Magento\TestFramework\Bootstrap::ADMIN_EMAIL,
    'admin-firstname' => \Magento\TestFramework\Bootstrap::ADMIN_FIRSTNAME,
    'admin-lastname' => \Magento\TestFramework\Bootstrap::ADMIN_LASTNAME,

I also tried removing 'db-port' => '33060', and replaced 'db-host' => 'localhost', with 'db-host' => 'localhost:33060', and still it doesn't recognize the host.

Also, I can succesfully connect to the MySQL server using Workbench.

Anyone know how to change the port reference?

1 Answer 1


Seems to be impossible as of Magento 2.1.

The database connection \Magento\TestFramework\Db\Mysql gets instantiated based on the configuration in \Magento\TestFramework\Application::getDbInstance(). The parameters are:


and that DB class does not use a port parameter anywhere.

So currently the only way around it is to forward the port to the default 3306

Good news is, there is a merged pull request: https://github.com/magento/magento2/pull/4275

So with Magento 2.2 you will be able to use 'db-host' => 'localhost:33060',

  • Thanks fab, that's what I've done. forward the port to the default 3306. Cheers!
    – vhen
    Commented Jul 2, 2017 at 3:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.