Running Craft Version 2.6.2994 on an EC2 instance that has PHP 7.0.21, and MySQL v 5.6.37 installed. When I try to create a new Matrix, I get the following error when saving.
When I test this on my localhost, which has PHP 7.1.5 and MySQL 5.6.35 running Valet, everything seems to work fine so I'm not sure if this is an issue with the version of PHP/MySQL, or in the code. I've also tried it with the root MySQL user having full permissions and it still gives the same error.
CDbCommand failed to execute the SQL statement: SQLSTATE[42000]:
Syntax error or access violation: 1064 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 'COLLATE=' at line 9
The entire project shows 'COLLATE='
appears in ~2 locations:
MysqlSchema.php, LN 198:
$options = 'ENGINE='.$engine.' DEFAULT CHARSET='.craft()->config->get('charset', ConfigFile::Db).' COLLATE='.craft()->config->get('collation', ConfigFile::Db).($options ? ' '.$options : '');`
And DbHelper.php, LN 219:
$def .= ' COLLATE '.$config['collation'];
Current Plugins Installed:
- Expanded Singles 0.2.5
- JSON Decode Twig Filter 1.0.9
- Neo 1.4.1
- Reasons 1.0.10
- Relabel 0.1.3
- SEO 1.4.7
- Sidebar enhancer 1.0.9
- The Architect 1.6.0
Edit: Full stack trace:
2017/11/07 16:28:18 [error] [system.db.CDbCommand] CDbCommand::execute() failed: SQLSTATE[42000]: Syntax error or access violation: 1064 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 'COLLATE=' at line 9. The SQL statement executed was: CREATE TABLE `craft_matrixcontent_test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`elementId` INT(11) NOT NULL,
`locale` CHAR(12) NOT NULL,
`dateCreated` datetime NOT NULL,
`dateUpdated` datetime NOT NULL,
`uid` CHAR(36) NOT NULL DEFAULT 0,
PRIMARY KEY (id)
) ENGINE=InnoDb DEFAULT CHARSET= COLLATE=.
2017/11/07 16:28:18 [error] [exception.CDbException] CDbException: CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 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 'COLLATE=' at line 9 in /var/www/craft/app/framework/db/CDbCommand.php:358
Stack trace:
#0 /var/www/craft/app/framework/db/CDbCommand.php(1352): CDbCommand->execute()
#1 /var/www/craft/app/etc/db/DbCommand.php(507): CDbCommand->createTable('craft_matrixcon...', Array, NULL)
#2 /var/www/craft/app/services/MatrixService.php(1071): Craft\DbCommand->createTable('craft_matrixcon...', Array)
#3 /var/www/craft/app/services/MatrixService.php(535): Craft\MatrixService->_createContentTable('matrixcontent_t...')
#4 /var/www/craft/app/fieldtypes/MatrixFieldType.php(152): Craft\MatrixService->saveSettings(Object(Craft\MatrixSettingsModel), false)
#5 /var/www/craft/app/services/FieldsService.php(646): Craft\MatrixFieldType->onAfterSave()
#6 /var/www/craft/app/controllers/FieldsController.php(122): Craft\FieldsService->saveField(Object(Craft\FieldModel))
#7 /var/www/craft/app/framework/web/actions/CInlineAction.php(49): Craft\FieldsController->actionSaveField()
#8 /var/www/craft/app/framework/web/CController.php(308): CInlineAction->runWithParams(Array)
#9 /var/www/craft/app/framework/web/CController.php(286): CController->runAction(Object(CInlineAction))
#10 /var/www/craft/app/framework/web/CController.php(265): CController->runActionWithFilters(Object(CInlineAction), Array)
#11 /var/www/craft/app/framework/web/CWebApplication.php(282): CController->run('saveField')
#12 /var/www/craft/app/etc/web/WebApp.php(823): CWebApplication->runController('fields/saveFiel...')
#13 /var/www/craft/app/etc/web/WebApp.php(287): Craft\WebApp->_processActionRequest()
#14 /var/www/craft/app/framework/base/CApplication.php(185): Craft\WebApp->processRequest()
#15 /var/www/craft/app/index.php(62): CApplication->run()
#16 /var/www/public/index.php(31): require_once('/var/www/craft/...')
#17 {main}
REQUEST_URI=/admin/settings/fields/new?groupId=3
HTTP_REFERER=http://ipaddress/admin/settings/fields/new?groupId=3
---
ENGINE=InnoDb DEFAULT CHARSET= COLLATE=
withcraft()->config->get('collation',ConfigFile::Db)
returning Null. Not sure where thats supposed to be getting its value. On local host, it returns the correct value, but not in the EC2 instance..craft/config/db.php
?post_max_size
/max_input_vars
values?craft()->config->get()
function wasn't able to pull in the default values like it normally does forcollation
andcharset
. Adding those both into the db.php settings fixed the issue though.