This MySql query runs fine in Windows:

CREATE TABLE `posts`.`table` (
   PRIMARY KEY (`idTable`));

In Ubuntu, it is giving the following error:

ERROR 1067: Invalid default value for 'Column1'

How do I give CURRENT_TIMESTAMP as the default value for 'Column1' in Ubuntu?

The version of MySql is this:

mysql Ver 14.14 Distrib 5.5.43, for debian-linux-gnu (x86_64) using readline 6.3

  • Different versions installed. What does select @@version; show in both (Windows and Linux)? I think the option for DEFAULT CURRENT_TIMESTAMP for datetime columns was added in 5.6 version. Your Linux installation has probably an older version. Jul 15 '15 at 19:11

The reason is the different versions installed in the two environments.

The option for DEFAULT CURRENT_TIMESTAMP for datetime columns was added in 5.6 version (specifically in 5.6.5). See the doumentation about the DATE, DATETIME, and TIMESTAMP Types:

The TIMESTAMP and (as of MySQL 5.6.5) DATETIME data types offer automatic initialization and updating to the current date and time. For more information, see Section 11.3.5, “Automatic Initialization and Updating for TIMESTAMP and DATETIME.

Most probably your Linux installation has an older version while the Windows has a newer. The solution would be to upgrade to the newer version (or have it installed besides the old).

General info about upgrading from 5.5 to 5.6 here: Upgrading from MySQL 5.5 to 5.6 and specific about upgrading in Ubuntu 14.04 LTS.

Don't forget to backup your data before you upgrade and run mysql_upgrade immediately after.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.