1

I keep getting the error Environment variable GLOBAL_DB_DRIVER was neither 'mysql' nor 'pgsql'. Aborting. when trying to pull the database from the production server to staging using Craft Script.

enter image description here

I have set the GLOBAL_DB_DRIVER="mysql", but the error is still there.

Below is my .env.sh settings,

# The path of the `craft` folder, relative to the root path; paths should always have a trailing /
GLOBAL_CRAFT_PATH="./"

# The maximum age of db backups in days; backups older than this will be automatically removed
GLOBAL_DB_BACKUPS_MAX_AGE=90

# The database driver for this Craft install ('mysql' or 'pgsql')
GLOBAL_DB_DRIVER="mysql"

# -- LOCAL settings --

# Local path constants; paths should always have a trailing /
LOCAL_ROOT_PATH="/var/www/html/test/"
LOCAL_ASSETS_PATH=${LOCAL_ROOT_PATH}"web/assets/images/"

# Local user & group that should own the Craft CMS install
LOCAL_CHOWN_USER="nobody"
LOCAL_CHOWN_GROUP="nogroup"

# Local directories relative to LOCAL_ROOT_PATH that should be writeable by the $CHOWN_GROUP
LOCAL_WRITEABLE_DIRS=(
                "${GLOBAL_CRAFT_PATH}storage"
                "web/cpresources"
                "web/assets"
                )

# Absolute paths to directories to back up, in addition to `LOCAL_ASSETS_DIRS` and `LOCAL_CRAFT_FILE_DIRS`
LOCAL_DIRS_TO_BACKUP=(
                  "/var/www/html/test/backups"
                )

# Local database constants; default port for mysql is 3306, default port for postgres is 5432
LOCAL_DB_NAME="test"
LOCAL_DB_PASSWORD="*****"
LOCAL_DB_USER="user"
LOCAL_DB_HOST="host"
LOCAL_DB_PORT="3306"
LOCAL_DB_SCHEMA="public"

# If you are using mysql 5.6.10 or later and you have `login-path` setup as per:
# https://opensourcedbms.com/dbms/passwordless-authentication-using-mysql_config_editor-with-mysql-5-6/
# you can use it instead of the above LOCAL_DB_* constants; otherwise leave this blank
LOCAL_DB_LOGIN_PATH=""

# The `mysql` and `mysqldump` commands to run locally
LOCAL_MYSQL_CMD="mysql"
LOCAL_MYSQLDUMP_CMD="mysqldump"

# Local backups path; paths should always have a trailing /
LOCAL_BACKUPS_PATH="/var/www/html/test/backups/"

# -- REMOTE settings --

# Remote ssh credentials, [email protected] and Remote SSH Port
REMOTE_SSH_LOGIN="[email protected]"
REMOTE_SSH_PORT="7722"

# Should we connect to the remote database server via ssh?
REMOTE_DB_USING_SSH="yes"

# Remote path constants; paths should always have a trailing /
REMOTE_ROOT_PATH="/var/www/html/test/"
REMOTE_ASSETS_PATH=${REMOTE_ROOT_PATH}"web/assets/images"

# Remote database constants; default port for mysql is 3306, default port for postgres is 5432
REMOTE_DB_NAME="test"
REMOTE_DB_PASSWORD="*****"
REMOTE_DB_USER="user"
REMOTE_DB_HOST="prod-host"
REMOTE_DB_PORT="3306"
REMOTE_DB_SCHEMA="public"

# If you are using mysql 5.6.10 or later and you have `login-path` setup as per:
# https://opensourcedbms.com/dbms/passwordless-authentication-using-mysql_config_editor-with-mysql-5-6/
# you can use it instead of the above REMOTE_DB_* constants; otherwise leave this blank
REMOTE_DB_LOGIN_PATH=""

# The `mysql` and `mysqldump` commands to run remotely
REMOTE_MYSQL_CMD="mysql"
REMOTE_MYSQLDUMP_CMD="mysqldump"

# Remote backups path; paths should always have a trailing /
REMOTE_BACKUPS_PATH="/var/www/html/test/backups/"

# Remote Amazon S3 bucket name
REMOTE_S3_BUCKET="test-storage"

Here is my system, both staging, and production using the same

PHP version 7.4.18
OS version  Linux 5.4.0-1047-aws
Database driver & version   MySQL 5.5.5
Craft edition & version Craft Pro 3.6.13

1 Answer 1

1

The error you're seeing is probably caused by this:

./.env.sh: line 128: $'\r': command not found

This error indicates that your OS doesn't recognise the line endings in this file. This means the file isn't parsed correctly, which in turn means your environment variables are wrong (for example, the GLOBAL_DB_DRIVER might include a control character at the end, which would explain your current problem). The most common cause is that you're developing on Windows or WSL which uses different line endings from Unix/Mac systems. Here are some resources to fix this:

Also, you might want to look into how this error occured in the first place. If you cloned the repository using git, it can automatically handle line ending conversions. Make sure to check the settings according to this guide.

1
  • Thanks. Let me have a try.
    – Lee
    Commented Jul 21, 2021 at 10:17

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.