How to get database dump in Drupal 8 without Backup and Migrate

  1. Enable Devel module
  2. Go to /devel/php
  3. Execute next snippet:
    // Get database connection information.
    $database = \Drupal::database()->getConnectionOptions();
    $DBUSER=$database['username'];
    $DBPASSWD=$database['password'];
    $DATABASE=$database['database'];
    // Set filename for download.
    $filename = $_SERVER['HTTP_HOST'] . '-' . date("Y-m-d--H-i") . ".sql.gz";
    // Send headers.
    header('Content-Type: application/x-gzip');
    header('Content-Disposition: attachment; filename="' . $filename . '"');
    // Execute command in terminal.
    $cmd = "mysqldump -u $DBUSER --password=$DBPASSWD $DATABASE | gzip --best";
    passthru($cmd);
    exit(0);

That's it! After clicking on `Execute` button browser will start downloading of database dump. 

English