I have a running Drupal 6.10 web site with ISP1.
I decided to switch from ISP1 to ISP2.
I am trying to transfer the DB right now.
There is a problem with transferring the user table.
The DB backup program (on ISP1) generates this script:
/* ******* start of users ********** */
DROP TABLE IF EXISTS users;
CREATE TABLE users (
uid int(10) unsigned NOT NULL auto_increment,
name varchar(60) NOT NULL,
pass varchar(32) NOT NULL,
mail varchar(64),
mode tinyint(4) DEFAULT '0' NOT NULL,
sort tinyint(4) DEFAULT '0',
threshold tinyint(4) DEFAULT '0',
theme varchar(255) NOT NULL,
signature varchar(255) NOT NULL,
created int(11) DEFAULT '0' NOT NULL,
access int(11) DEFAULT '0' NOT NULL,
login int(11) DEFAULT '0' NOT NULL,
status tinyint(4) DEFAULT '0' NOT NULL,
timezone varchar(8),
language varchar(12) NOT NULL,
picture varchar(255) NOT NULL,
init varchar(64),
data longtext,
PRIMARY KEY (uid),
UNIQUE name (name),
KEY created (created),
KEY access (access),
KEY mail (mail)
);
INSERT INTO xeuro_users (uid, name, pass, mail, mode, sort, threshold, theme, signature, created, access, login, status, timezone, language, picture, init, data) VALUES
('0', '', '', '', '0', '0', '0', '', '', '0', '0', '0', '0', '', '', '', '', ''),
('1', 'jozobozo', '611b25d6096815681506d6fccf3f694d', 'xxx.yyy@gmail.com', '0', '0', '0', '', '', '1204397834', '1239145729', '1239143441', '1', '0', '', '', 'xxx.yyy@gmail.com', 'a:1:{s:7:\"contact\";i:0;}');
If I run the script at ISP2, I receive this message:
MySQL said: Documentation
#1062 - Duplicate entry '1' for key 1
When I browse the table I can see that the first row has been inserted but the uid value (auto increment) is 1 and not 0.
Obviously, trying to insert second row causes the error.
I tried to "force" the auto increment to start with 0 using
ALTER TABLE users auto_increment = 0;
in between CREATE TABLE and INSERT INTO, but auto increment started again at 1
If I try to start auto increment at 10, it works.
How can I "force" MySql to start the auto_increment with 0?
How can I by-pass this problem?
Is the ('0', '', '', '', '0', '0', '0', '', '', '0', '0', '0', '0', '', '', '', '', '') row necessary in the DB table users?
Thanks.
Comments
If your MySQL version is
If your MySQL version is recent enough you may be able to fix this by adding at the top of your import the line
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";Otherwise you could try to postpone specifying the uid field as auto_increment, import the table, and alter it later.
Yes, I tried SET SESSION
Yes, I tried SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" and it worked.
Thank you.