V
V
Vyacheslav Grachunov2019-01-03 22:35:54
MySQL
Vyacheslav Grachunov, 2019-01-03 22:35:54

How to allow zero dates in MariaDB?

You need to transfer a backup from one server to another.
But in the backup there are, for example, such constructions:
`dt` timestamp DEFAULT NULL,
I.e. the default date field is NULL, and in new versions of MySQL this is prohibited
. On the Internet, it is suggested to write this to a file in /etc/mysql/conf.d/:

[mysqld]
sql_mode=IGNORE_SPACE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Judging by the result of the query, the mode really changes, but it's no use - MariaDB base version 10.1.37 What's the matter? Why does not it work?
show variables like 'sql_mode'
1067 - Invalid default value for 'dt'

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Shitskov, 2019-01-03
@Zarom

Try it:
I think this is the case - you have `dt` by default 'NOT NULL'

V
Vitaliy Orlov, 2019-01-03
@orlov0562

Read about explicit_defaults_for_timestamp
explicit_defaults_for_timestamp is enabled, the server disables the nonstandard behaviors and handles TIMESTAMP columns as follows:
- It is not possible to assign a TIMESTAMP column a value of NULL to set it to the current timestamp. To assign the current timestamp, set the column to CURRENT_TIMESTAMP or a synonym such as NOW().
as I understand it, you can disable this option during import or replace it in the dump
with
** code not checked, taken from here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question