Я пытаюсь создать базу данных, если она не существует, и установить привилегии, но у меня возникают проблемы с тем, чтобы заставить ее работать, я продолжаю получать You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci' at line 1
Я включил различные способы, которыми япытался выполнить команды
Yaml:
initContainers:
- name: database-setup
image: mysql:5.7
imagePullPolicy: IfNotPresent
# command: ["rm", "-fr", "/var/lib/mysql/lost+found"]
# SQL Syntax error:
command: [sh,-c,mysql -h mysql-service -p$MYSQL_ROOT_PASSWORD -e "CREATE DATABASE IF NOT EXISTS `$WORDPRESS_DB_NAME` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; GRANT ALL PRIVILEGES ON $WORDPRESS_DB_NAME.* TO '$WORDPRESS_DB_USER'@'%' IDENTIFIED BY '$WORDPRESS_DB_PASSWORD'; FLUSH PRIVILEGES;"]
# Enviroment Variables arn't passed into mysql shell:
# - sh
# - -c
# - mysql -h mysql-service -p$MYSQL_ROT_PASSWORD
# - CREATE DATABASE IF NOT EXISTS $WORDPRESS_DB_NAME DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# - GRANT ALL PRIVILEGES ON $WORDPRESS_DB_NAME.* TO '$WORDPRESS_DB_USER'@'%' IDENTIFIED BY '$WORDPRESS_DB_PASSWORD';
# - FLUSH PRIVILEGES;
# - EXIT;
# SQL Syntax error:
# - sh
# - -c
# - mysql -h mysql-service -p$MYSQL_ROOT_PASSWORD -e "CREATE DATABASE IF NOT EXISTS `$WORDPRESS_DB_NAME` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; GRANT ALL PRIVILEGES ON $WORDPRESS_DB_NAME.* TO '$WORDPRESS_DB_USER'@'%' IDENTIFIED BY '$WORDPRESS_DB_PASSWORD'; FLUSH PRIVILEGES;
env:
- name: WORDPRESS_DB_NAME
value: wordpress-green
- name: WORDPRESS_DB_USER
value: wordpress-green
- name: WORDPRESS_DB_PASSWORD
valueFrom:
secretKeyRef:
name: wordpress-mysql-pass
key: wordpress-mysql-pass
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-root-pass
key: mysql-root-pass