Keywords: Drupal - Linux - Technical issue - Other
Description:
If you install Drush with composer the latest version will be 10.3.x. This version adds the parameter '--defaults-file' to the commands that interact directly with MySQL like 'drush sqlc' or 'drush sql-dump'. Because Bitnami's wrapper /opt/bitnami/mysql/bin/mysql already does that automatically we get the error:
bash-4.2# drush sqlc --debug
[preflight] Config paths: /opt/bitnami/apps/drupal/vendor/drush/drush/drush.yml
[preflight] Alias paths: /opt/bitnami/apps/drupal/web/drush/sites,/opt/bitnami/apps/drupal/drush/sites
[preflight] Commandfile search paths: /opt/bitnami/apps/drupal/vendor/drush/drush/src,/opt/bitnami/apps/drupal/drush
[debug] Starting bootstrap to max [0.07 sec, 8.07 MB]
[debug] Drush bootstrap phase: bootstrapDrupalRoot() [0.07 sec, 8.07 MB]
[debug] Change working directory to /opt/bitnami/apps/drupal/web [0.07 sec, 8.07 MB]
[debug] Initialized Drupal 8.9.13 root directory at /opt/bitnami/apps/drupal/web [0.07 sec, 8.21 MB]
[debug] Drush bootstrap phase: bootstrapDrupalSite() [0.07 sec, 8.57 MB]
[debug] Initialized Drupal site default at sites/default [0.07 sec, 8.74 MB]
[debug] Drush bootstrap phase: bootstrapDrupalConfiguration() [0.07 sec, 8.74 MB]
[debug] Add service modifier [0.07 sec, 8.98 MB]
[info] Executing: command -v mysql [0.08 sec, 9.45 MB]
[info] Executing: mysql --defaults-file=/tmp/drush_3gHWcy --database=bitnami_drupal8 --socket=/opt/bitnami/mysql/tmp/mysql.sock --port=3306 -A [0.09 sec, 9.51 MB]
mysql.bin: [ERROR] unknown variable 'defaults-file=/tmp/drush_3gHWcy'.
I fixed this issue by adding another case statement for when the -defaults-file is already present to /opt/bitnami/mysql/bin/mysql:
#!/bin/sh
LD_LIBRARY_PATH=/opt/bitnami/mysql/lib:/opt/bitnami/mysql/../common/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
export LD_LIBRARY_PATH
case "$@" in
*--no-defaults*)
exec $0.bin "$@"
;;
*--defaults-extra-file*)
exec $0.bin "$@"
;;
*--defaults-file*)
exec $0.bin "$@"
;;
esac
exec $0.bin --defaults-file=/opt/bitnami/mysql/my.cnf "$@"
Posting this because this can be useful for others and maybe Bitnami can take a look at this issue.
Thansk!