MySQL error when creating custom table
-
Running WordPress 6.5, php 8.1 and MySQL 8.0 on an openlitespeed server.
I’ve just installed pods on a clean WordPress install to test it out. I’ve enabled the Advanced Content Type component and attempted to create a custom data structure called “company” in the admin UI.
When trying to create the table, it throws a MySQL error:
Error: Database Error; SQL: CREATE TABLE wp_5_pods_company (id BIGINT(20) UNSIGNED AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), created DATETIME NOT NULL default "0000-00-00 00:00:00", modified DATETIME NOT NULL default "0000-00-00 00:00:00", permalink VARCHAR(200)) DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_unicode_520_ci; Response: 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 '"0000-00-00 00:00:00", modified DATETIME NOT NULL default "0000-00-00 00:00:00' at line 1
When trying to run the CREATE TABLE sql statement manually, I found that it was failing due to the double-quotes around the DATETIME default values. The sql executes correctly when replacing the double-quotes with single-quotes.
- The topic ‘MySQL error when creating custom table’ is closed to new replies.