I have a website that it's running ok in Docker/Azure.

I have this configuration in my settings.php

$databases ['default'] ['default'] = array (
    'database' => getenv ( 'MYSQL_DATABASE' ),
    'username' => getenv ( 'MYSQL_USER' ),
    'password' => getenv ( 'MYSQL_PASSWORD' ),
    'prefix' => '',
    'host' => getenv ( 'MYSQL_HOSTNAME' ),
    'port' => getenv ( 'MYSQL_PORT' ),
    'driver' => 'mysql'

When I make drush status

I get this.

 Drupal version   : 8.7.3                                      
 Site URI         : http://default                             
 DB driver        :                                       
 DB hostname      :                                      
 DB port          :                                        
 DB username      :                                 
 DB name          : 

Any idea how to make that Drush get the mysql configuration options?


  • Did you try adding unix_socket' => '/PATH/TO/SOCKET', ? – berramou Jul 11 '19 at 9:19
  • Hello Berramou, no the problem it's not the socket, Drush it's not able to get the enviroment variable that Docker pass to the server. – Oskar Calvo Jul 11 '19 at 9:40
  • 1
    As always, turn on debugging to get some more info - drush -d status. The output you posted must be truncated? Update your question with more info. – hansfn Jul 12 '19 at 5:21

It looks like the environment variables are defined only for HTTP requests. In other words, they seem to be set in FPM, NGINX, or Apache, but not in your shell.

Try typing echo $MYSQL_DATABASE in your shell. If that outputs nothing, you'll have to export the environment variables first, so Drush can see them.

  • Yes, at the end we have export all the enviroment variables to bash_rc so Drush can get them. – Oskar Calvo Jul 18 '19 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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