diff --git a/docs/source/users-guide.rst b/docs/source/users-guide.rst index 6fb45aa08..2f8be5d4f 100644 --- a/docs/source/users-guide.rst +++ b/docs/source/users-guide.rst @@ -981,6 +981,19 @@ The following sample may be added to the Fabric CA server configuration file in order to connect to a MySQL database. Be sure to customize the various values appropriately. +On MySQL 5.7.X, certain modes affect whether the server permits '0000-00-00' as a valid date. +It might be necessary to relax the modes that MySQL server uses. We want to allow +the server to be able to accept zero date values. + +In my.cnf, find the configuration option *sql_mode* and remove *NO_ZERO_DATE* if present. +Restart MySQL server after making this change. + +Please refer to the following MySQL documentation on different modes available +and select the appropriate settings for the specific version of MySQL that is +being used. + +https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html + :: db: @@ -1546,16 +1559,6 @@ https://www.postgresql.org/docs/9.4/static/libpq-ssl.html MySQL SSL Configuration ~~~~~~~~~~~~~~~~~~~~~~~ -On MySQL 5.7.X, certain modes affect whether the server permits '0000-00-00' as a valid date. -It might be necessary to relax the modes that MySQL server uses. We want to allow -the server to be able to accept zero date values. - -Please refer to the following MySQL documentation on different modes available -and select the appropriate settings for the specific version of MySQL that is -being used. - -https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html - **Basic instructions for configuring SSL on MySQL server:** 1. Open or create my.cnf file for the server. Add or uncomment the diff --git a/lib/dbutil/dbutil.go b/lib/dbutil/dbutil.go index b4e509ee4..6bd907fde 100644 --- a/lib/dbutil/dbutil.go +++ b/lib/dbutil/dbutil.go @@ -283,7 +283,7 @@ func createMySQLTables(datasource string, dbName string, db *sqlx.DB) error { return fmt.Errorf("Error creating affiliations table: %s", err) } log.Debug("Created affiliations table") - if _, err := database.Exec("CREATE TABLE certificates (id VARCHAR(64), serial_number varbinary(128) NOT NULL, authority_key_identifier varbinary(128) NOT NULL, ca_label varbinary(128), status varbinary(128) NOT NULL, reason int, expiry timestamp DEFAULT '1970-01-01 00:00:01', revoked_at timestamp DEFAULT '1970-01-01 00:00:01', pem varbinary(4096) NOT NULL, PRIMARY KEY(serial_number, authority_key_identifier)) DEFAULT CHARSET=utf8 COLLATE utf8_bin"); err != nil { + if _, err := database.Exec("CREATE TABLE certificates (id VARCHAR(64), serial_number varbinary(128) NOT NULL, authority_key_identifier varbinary(128) NOT NULL, ca_label varbinary(128), status varbinary(128) NOT NULL, reason int, expiry timestamp DEFAULT 0, revoked_at timestamp DEFAULT 0, pem varbinary(4096) NOT NULL, PRIMARY KEY(serial_number, authority_key_identifier)) DEFAULT CHARSET=utf8 COLLATE utf8_bin"); err != nil { return fmt.Errorf("Error creating certificates table: %s", err) } log.Debug("Created certificates table")