|
|
| Author |
Message |
chris Dark Lord of the Sith

Joined: 10 May 2003 Posts: 6262 Location: Outer Space
|
Posted: Thu Jun 09, 2005 10:54 pm Post subject: MySQL error 1067 (42000): Invalid default value for 'ban_id' |
|
|
|
Problem: You run a create table command like:
| Code: |
#
# Table structure for table 'phpbb_banlist'
#
CREATE TABLE phpbb_banlist (
ban_id mediumint(8) unsigned DEFAULT '0' NOT NULL auto_increment,
ban_userid mediumint(8) DEFAULT '0' NOT NULL,
ban_ip varchar(8) DEFAULT '' NOT NULL,
ban_email varchar(255),
PRIMARY KEY (ban_id),
KEY ban_ip_user_id (ban_ip,ban_userid)
);
|
but get (unexpectedly) the error:
| Code: |
ERROR 1067 (42000) at line 35: Invalid default value for 'ban_id'
|
Reason: In the later versions of MySQL (maybe starting 5.x), you cannot set a default value to an "auto increment" field (if you think about it, it doesn't make much sense either).
Solution: Take out the DEFAULT part whenever you have specified "auto_increment" too. In vi and sed, you can do this with the command:
| Code: |
s/\(.*\)DEFAULT '0'\(.*\)auto_increment/\1\2auto_increment/
|
_________________ Regards
Chris Karakas
www.karakas-online.de |
|
| Back to top |
|
 |
frigo Private

Joined: 06 Jul 2005 Posts: 1 Location: Ecuador
|
Posted: Wed Jul 06, 2005 6:52 pm Post subject: ERROR 1067 (42000): Invalid default value for 'id' |
|
|
|
I am a novice in linux and mysql, I have the same problem (ERROR 1067 (42000): Invalid default value for 'id') when I to create a table (create table <name_table> (id int auto_increment not null default '0' primary key, ...) , I do not understand how should I run the solution (s/\(.*\)DEFAULT '0'\(.*\)auto_increment/\1\2auto_increment/).
Thanks by any idea.
frigo. |
|
| Back to top |
|
 |
chris Dark Lord of the Sith

Joined: 10 May 2003 Posts: 6262 Location: Outer Space
|
Posted: Thu Jul 14, 2005 8:35 pm Post subject: |
|
|
|
Open your sql file (the file that contains your SQL commands) in vi. Then type ":" (without the double quotes) and then type the above command. _________________ Regards
Chris Karakas
www.karakas-online.de |
|
| Back to top |
|
 |
AAAGROUP Private

Joined: 11 Aug 2008 Posts: 1 Location: PR
|
Posted: Mon Aug 11, 2008 7:27 am Post subject: #1067 - Invalid default value for 'auct_id' |
|
|
|
i try create table but say error
>>>>>>
i try create manual table but say error phpmyadmin
| Code: |
Error
SQL query:
CREATE TABLE `ANSERV_sellfields` (
`auct_id` int( 32 ) NOT NULL default '',
KEY id( auct_id )
) TYPE = MYISAM
MySQL said:
#1067 - Invalid default value for 'auct_id'
|
how fixed?
my phpMyAdmin Version is
Server version: 5.0.51a-community
| chris wrote: | Open your sql file (the file that contains your SQL commands) in vi. Then type ":" (without the double quotes) and then type the above command. |
[edit] Included code in code tags. Chris [/edit] _________________ AMG |
|
| Back to top |
|
 |
|
|
 |
|
|