I can’t create a table on my phpmyadmin… date is alway invalid… I already used TIMESTAMP and DATETIME datatype.. but still got some errors…
mysql version: 5.7.14 and im using wamp
asked Mar 10, 2017 at 7:08
1
Possible the strict mode and NO_ZERO_DATE are enabled. This pair produces an error on zero dates.
Check the SQL_MODE and have a look at this page — NO_ZERO_DATE
answered Mar 10, 2017 at 7:16
DevartDevart
119k23 gold badges163 silver badges185 bronze badges
3
Put default TimeStamp to:
CURRENT_TIMESTAMP
answered Mar 10, 2017 at 7:13
Your date_created column has type timestamp and you are giving 0000-00-00 00:00 as default value, which is incorrect for timestamp, you can select CURRENT_TIMESTAMP for this column.
answered Mar 10, 2017 at 7:16
Your default for date_crated value is incorrect.
From https://dev.mysql.com/doc/refman/5.7/en/datetime.html
The range for TIMESTAMP values is ‘1970-01-01 00:00:01.000000’ to
‘2038-01-19 03:14:07.999999’
Typically, you should set the default to CURRENT_TIMESTAMP
IMPORTANT NOTE
This solution will only work until January 19, 2038, at 3:14:07 AM. Which is, by the time of writing this answer, about 21 years away. So to future programmers, if MySQL does not update/fix this limitation, you will have a problem and must find a workaround.
answered Mar 10, 2017 at 7:14
GreesoGreeso
7,4029 gold badges51 silver badges75 bronze badges
There seems to be no solution to this problem. It does not matter what I do, if I use CURRENT_TIMESTAMP, or ‘1970….’, a normal valid date, NULL, just nothing, or whatever,
and even if I run:
SET SQL_MODE='ALLOW_INVALID_DATES';
(that command actually succeeds)
.. but it is still error #1067. Nothing helps.
I move over to Ubuntu now, where I have no problems with this.
answered Feb 9, 2020 at 9:42
Perry JPerry J
3553 silver badges16 bronze badges
0
Ah, I finally fixed it also in phpMyAdmin!
Just run from the SQL panel in phpMyAdmin:
SHOW VARIABLES LIKE 'sql_mode';
In my case, I had NO_ZERO_DATE here.
I then set this to exactly what I use on my Ubuntu system:
set global sql_mode='NO_ENGINE_SUBSTITUTION';
Now it all works using ‘0000-00-00 00:00’ as default value
answered Feb 9, 2020 at 10:43
Perry JPerry J
3553 silver badges16 bronze badges
The question is too broad for the answer. There are many problems regarding these questions, even more so when the incompatibility of the different MySQL-based engines is notorious.
For me the best option is to know the state of variables at the time of making the backup with the option —opt (mysqldump —opt) and apply it to our backup if it does not have it as usual, either because the original backup I did not have it, or because the one that has happened to us is incorrect.
If the backup does not contain the settings with which it was made, we will have to start investigating, but basically we can do it like this.
Add SETtings to header of backup
echo '
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!50606 SET @OLD_INNODB_STATS_AUTO_RECALC=@@INNODB_STATS_AUTO_RECALC */;
/*!50606 SET GLOBAL INNODB_STATS_AUTO_RECALC=OFF */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;' | cat - mybackup.sql > temp && mv temp mybackup.sql
Add restore SETtings to end
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!50606 SET GLOBAL INNODB_STATS_AUTO_RECALC=@OLD_INNODB_STATS_AUTO_RECALC */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;' >> mybackup.sql
If you don’t have those settings you can make a mysqldump backup with the —opt option on the original server, in order to get them.
If you don’t have it, you can go little by little, setting the necessary settings, both at the start and at the exit.
Вы не вошли. Пожалуйста, войдите или зарегистрируйтесь.
Активные темы Темы без ответов
Страницы 1
Чтобы отправить ответ, вы должны войти или зарегистрироваться
1 2009-09-29 02:08:19
- blackcherry
- Новичок
- Неактивен
- Зарегистрирован: 2009-09-29
- Сообщений: 1
Тема: Ошибка 1067 как исправить?
Первый раз столкнулась с базой данных. Помогите! Что где исправить?
SQL-запрос:
CREATE TABLE faq_categories(
id int( 11 ) DEFAULT ‘0’ NOT NULL AUTO_INCREMENT ,
title varchar( 255 ) NOT NULL ,
PRIMARY KEY ( id ) ,
UNIQUE id_2( id ) ,
KEY id( id )
);
Ответ MySQL:
#1067 — Invalid default value for ‘id’
2 Ответ от Hanut 2009-09-29 12:00:24
- Hanut
- Модератор
- Неактивен
- Откуда: Рига, Латвия
- Зарегистрирован: 2006-07-02
- Сообщений: 9,726
Re: Ошибка 1067 как исправить?
blackcherry
У поля id являющееся первичным (PRIMARY) ключом и имеющем аттрибут AUTO_INCREMENT, не может быть значения по умолчанию (DEFAULT). Уберите из запроса: DEFAULT ‘0’.
Сообщения 2
Страницы 1
Чтобы отправить ответ, вы должны войти или зарегистрироваться
Hi everyone i am getting an error trying to run the below query ERROR 1067 (42000): Invalid default value for ‘uploadedDate’
CREATE TABLE `filenew` (
`id` int(11) NOT NULL AUTO_INCREMENT /* MYSQL_TYPE_LONG */,
`originalFilename` varchar(255) CHARACTER SET utf8 NOT NULL /* MYSQL_TYPE_VARCHAR */,
`shortUrl` varchar(255) CHARACTER SET utf8 DEFAULT NULL /* MYSQL_TYPE_VARCHAR */,
`fileType` varchar(150) CHARACTER SET utf8 DEFAULT NULL /* MYSQL_TYPE_VARCHAR */,
`extension` varchar(10) CHARACTER SET utf8 DEFAULT NULL /* MYSQL_TYPE_VARCHAR */,
`fileSize` bigint(15) DEFAULT NULL /* MYSQL_TYPE_LONGLONG */,
`localFilePath` varchar(255) CHARACTER SET utf8 DEFAULT NULL /* MYSQL_TYPE_VARCHAR */,
`userId` int(11) DEFAULT NULL /* MYSQL_TYPE_LONG */,
`uploadedUserId` int(11) DEFAULT NULL /* MYSQL_TYPE_LONG */,
`totalDownload` int(11) DEFAULT NULL /* MYSQL_TYPE_LONG */,
`uploadedIP` varchar(45) CHARACTER SET utf8 DEFAULT NULL /* MYSQL_TYPE_VARCHAR */,
`uploadedDate` timestamp DEFAULT NULL /* MYSQL_TYPE_TIMESTAMP2 */,
`statusId` int(2) DEFAULT NULL /* MYSQL_TYPE_LONG */,
`status` enum('active','trash','deleted') DEFAULT 'active' /* MYSQL_TYPE_ENUM */,
`visits` int(11) DEFAULT '0' /* MYSQL_TYPE_LONG */,
`lastAccessed` timestamp DEFAULT NULL /* MYSQL_TYPE_TIMESTAMP2 */,
`deleteHash` varchar(32) CHARACTER SET utf8 DEFAULT NULL /* MYSQL_TYPE_VARCHAR */,
`folderId` int(11) DEFAULT NULL /* MYSQL_TYPE_LONG */,
`serverId` int(11) DEFAULT '1' /* MYSQL_TYPE_LONG */,
`adminNotes` text CHARACTER SET utf8 DEFAULT NULL /* MYSQL_TYPE_BLOB */,
`accessPassword` varchar(32) CHARACTER SET utf8 DEFAULT NULL /* MYSQL_TYPE_VARCHAR */,
`fileHash` varchar(32) CHARACTER SET utf8 DEFAULT NULL /* MYSQL_TYPE_VARCHAR */,
`minUserLevel` int(3) DEFAULT NULL /* MYSQL_TYPE_LONG */,
`linkedFileId` int(11) DEFAULT NULL /* MYSQL_TYPE_LONG */,
`keywords` varchar(255) CHARACTER SET utf8 DEFAULT NULL /* MYSQL_TYPE_VARCHAR */,
`description` varchar(255) CHARACTER SET utf8 DEFAULT NULL /* MYSQL_TYPE_VARCHAR */,
`isPublic` int(1) NOT NULL DEFAULT '1' /* MYSQL_TYPE_LONG */,
`total_likes` int(11) NOT NULL DEFAULT '0' /* MYSQL_TYPE_LONG */,
`uploadSource` enum('direct','remote','ftp','torrent','leech','webdav','api','fileimport','other') CHARACTER SET utf8 NOT NULL DEFAULT 'direct' /* MYSQL_TYPE_ENUM */,
`unique_hash` varchar(64) CHARACTER SET utf8 DEFAULT NULL /* MYSQL_TYPE_VARCHAR */,
`date_updated` datetime DEFAULT NULL /* MYSQL_TYPE_DATETIME2 */,
PRIMARY KEY (`id`),
UNIQUE KEY `unique_hash` (`unique_hash`),
KEY `shortUrl` (`shortUrl`),
KEY `originalFilename` (`originalFilename`),
KEY `fileSize` (`fileSize`),
KEY `visits` (`visits`),
KEY `lastAccessed` (`lastAccessed`),
KEY `extension` (`extension`),
KEY `userId` (`userId`),
KEY `statusId` (`statusId`),
KEY `userId_2` (`userId`),
KEY `uploadedDate` (`uploadedDate`),
KEY `folderId` (`folderId`),
KEY `serverId` (`serverId`),
KEY `fileHash` (`fileHash`),
KEY `linkedFileId` (`linkedFileId`),
KEY `statusId_2` (`statusId`),
KEY `uploadedUserId` (`uploadedUserId`),
KEY `keywords` (`keywords`),
KEY `status` (`status`),
KEY `uploadedIP` (`uploadedIP`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
I have tried many many fixes on Google and other forums but none of them worked, few things that i have tried are
Setting in my.cnf
sql_mode=NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Trying this
SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
…and many more. If someone could please help me out in this matter, because I am not experienced in databases, then I would really appreciate the help.
I am on centos 7 and MariaDB10.3.23-MariaD
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Closed
pma-import opened this issue
Feb 4, 2012
· 11 comments
Closed
Null checkbox behavior
#6056
pma-import opened this issue
Feb 4, 2012
· 11 comments
Comments
When you already have a not null column in a table click edit and uncheck the null checkbox.
You will get this error:
#1067 — Invalid default value for ‘user’
The sql syntax that PHPMyAdmin is trying to use is:
ALTER TABLE email CHANGE user user VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT NULL
It should be:
ALTER TABLE email CHANGE user user VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL
It doesn’t matter what kind of column it is. All the values are filled in. the problem is that it is using DEFAULT NULL at the end when you are removing NULL using the phpmyadmin interface.
- Original URL: https://sourceforge.net/p/phpmyadmin/feature-requests/1349/
- Original author: stokescomp
- assigned_to: nobody —> lem9
- Original author: lem9
The bug description is misleading, it should be «When you already have a null column…».
The «Default NULL» clause was generated because you did not change the default value after unchecking the null checkbox.
Moving to feature requests, to automate this change.
- Original author: lem9
- milestone: 2260955 —>
- labels: 509096 —> Data insertion/extraction/manipulation
- Original author: lem9
- summary: Fix unit test running individually by file #1067 — Invalid default value for ‘column’ when altering tb —> When you already have a null column you can get this error
- Original author: stokescomp
- assigned_to: lem9 —> nobody
- Original author: lem9
- summary: When you already have a null column you can get this error —> Null checkbox behavior
- Original author: lem9
- assigned_to: nobody —> lem9
- Original author: lem9
This requested feature was implemented in the repository and will be part of a future release; thanks for suggesting.
- Original author: lem9
- summary: Null checkbox behavior —> (ok 3.5) Null checkbox behavior
- priority: 5 —> 1
- status: open —> open-accepted
- Original author: lem9
- status: open-accepted —> closed-accepted
- Original author: lem9
- Status: closed-accepted —> fixed
- Original author: nijel
github-actions
bot
locked as resolved and limited conversation to collaborators
Jul 5, 2020
2 participants

