Stop data retention! Click here & act! Are you a webmaster and want to participate? Here you can find all necessary material for your website - Willst du auch an der Aktion teilnehmen? Hier findest du alle relevanten Infos und Materialien:
Chris Karakas Online Forum Index Karakas Online
 FAQFAQ   Forum SearchForum Search   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
MySQL error 1067 (42000): Invalid default value for 'ban_id'



 
Post new topic   Reply to topic
   Chris Karakas Online Forum Index -> Database Forum RSS Feed of this Forum
Share this page: These icons link to social bookmarking sites where readers can share and discover new web pages.Digg  del.icio.us  tc.eserver.org  Blinklist  Furl  Reddit  Blogmarks  Magnolia  Sphere  Yahoo!  Google  Windows Live  Technorati  Blue Dot  Simpy  Newsvine  Stumble Upon  co.mments.com  Blinkbits  BlogMemes  Connotea  View previous topic :: View next topic  
Author Message
chris
Dark Lord of the Sith


Joined: 10 May 2003
Posts: 6262
Location: Outer Space

PostPosted: Thu Jun 09, 2005 10:54 pm    Post subject: MySQL error 1067 (42000): Invalid default value for 'ban_id'
Reply with quote

Question 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'


Arrow 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).

Idea 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
View user's profile Send private message Send e-mail Visit poster's website
frigo
Private
Private


Joined: 06 Jul 2005
Posts: 1
Location: Ecuador

PostPosted: Wed Jul 06, 2005 6:52 pm    Post subject: ERROR 1067 (42000): Invalid default value for 'id'
Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
chris
Dark Lord of the Sith


Joined: 10 May 2003
Posts: 6262
Location: Outer Space

PostPosted: Thu Jul 14, 2005 8:35 pm    Post subject:
Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
AAAGROUP
Private
Private


Joined: 11 Aug 2008
Posts: 1
Location: PR

PostPosted: Mon Aug 11, 2008 7:27 am    Post subject: #1067 - Invalid default value for 'auct_id'
Reply with quote

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 quoteOpen your sql file (the file that contains your SQL commands) in vi. Then type ":" (without the double quotes) and then type the above command.Close quote


[edit] Included code in code tags. Chris [/edit]
_________________
AMG
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Share this page: These icons link to social bookmarking sites where readers can share and discover new web pages.Digg  del.icio.us  tc.eserver.org  Blinklist  Furl  Reddit  Blogmarks  Magnolia  Sphere  Yahoo!  Google  Windows Live  Technorati  Blue Dot  Simpy  Newsvine  Stumble Upon  co.mments.com  Blinkbits  BlogMemes  Connotea 
Display posts from previous:   
Post new topic   Reply to topic
   Chris Karakas Online Forum Index -> Database Forum
Page 1 of 1
This page contains valid HTML 4.01 Transitional - click here to check it!
This page contains a valid CSS - click here to check it!

 

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group