Skip to content

Commit e641efc

Browse files
committed
Fix MySQL ONLY_FULL_GROUP_BY
1 parent 0e0c783 commit e641efc

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

docker-compose.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ services:
4141
- "REDIS_FQDN=redis"
4242
- "INIT=true" # Initialze MISP, things includes, attempting to import SQL and the Files DIR
4343
- "CRON_USER_ID=1" # The MISP user ID to run cron jobs as
44-
# - "SYNCSERVERS=1 2 3 4" # The MISP Feed servers to sync in the cron job
44+
- "SYNCSERVERS=1 2" # The MISP Feed servers to sync in the cron job
4545
# Database Configuration (And their defaults)
4646
# - "MYSQL_HOST=db"
4747
# - "MYSQL_USER=misp"
48-
# - "MYSQL_PASSWORD=example" # NOTE: This should be AlphaNum with no Special Chars. Otherwise, edit config files after first run.
48+
# - "MYSQL_PASSWORD=example" # NOTE: This should be AlphaNum with no Special Chars. Otherwise, edit config files after first run.
4949
# - "MYSQL_DATABASE=misp"
5050
# Optional Settings
51+
# - "MYSQL_ROOT_PASSWORD=password" # Enable to allow fixing ONLY_FULL_GROUP_BY MySQL defaults
5152
# - "NOREDIR=true" # Do not redirect port 80
5253
# - "DISIPV6=true" # Disable IPV6 in nginx
5354
# - "SECURESSL=true" # Enable higher security SSL in nginx

server/files/entrypoint_nginx.sh

+16
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ MISP_APP_CONFIG_PATH=/var/www/MISP/app/Config
99
[ -z "$REDIS_FQDN" ] && REDIS_FQDN=redis
1010
[ -z "$MISP_MODULES_FQDN" ] && MISP_MODULES_FQDN="http://misp-modules"
1111
[ -z "$MYSQLCMD" ] && MYSQLCMD="mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -P $MYSQL_PORT -h $MYSQL_HOST -r -N $MYSQL_DATABASE"
12+
[ -z "$MYSQLROOTCMD" ] && MYSQLROOTCMD="mysql -u root -p$MYSQL_ROOT_PASSWORD -P $MYSQL_PORT -h $MYSQL_HOST -r -N $MYSQL_DATABASE"
1213

1314
ENTRYPOINT_PID_FILE="/entrypoint_apache.install"
1415
[ ! -f $ENTRYPOINT_PID_FILE ] && touch $ENTRYPOINT_PID_FILE
@@ -92,9 +93,24 @@ init_mysql(){
9293
exit 1
9394
fi
9495

96+
# If we're given the root password, disable the default sql_mode ONLY_FULL_GROUP_BY
97+
# in MySQL. Required until https://github.com/MISP/MISP/issues/1894 is fixed
98+
if [ -n "$MYSQL_ROOT_PASSWORD" ]; then
99+
echo -n "Checking if ONLY_FULL_GROUP_BY mode is enabled..."
100+
sql_mode=$(echo "SELECT @@sql_mode" | $MYSQLROOTCMD | grep "ONLY_FULL_GROUP_BY")
101+
if [ -n "$sql_mode" ]; then
102+
echo -e "\nDisabling MySQL default ONLY_FULL_GROUP_BY"
103+
echo "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));" | $MYSQLROOTCMD 1>/dev/null
104+
else
105+
echo " OK"
106+
fi
107+
fi
108+
95109
if [ $(isDBinitDone) -eq 0 ]; then
96110
echo "Database has already been initialized"
97111
else
112+
echo "Disabling MySQL default ONLY_FULL_GROUP_BY"
113+
echo "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));" | $MYSQLCMD 1>/dev/null
98114
echo "Database has not been initialized, importing MySQL scheme..."
99115
$MYSQLCMD < /var/www/MISP/INSTALL/MYSQL.sql
100116
fi

0 commit comments

Comments
 (0)