I'm working on localhost doing some pages with wordpress. Yesterday I've finished to work with some pages, and then I turn off my pc. Today when I turned it on and I've tried to reach some pages (after have turned theApache and Mysql services on) wordpress say i need to install the framework again.
This is the 1st error i get:
Well I just put the same name etc etc... and the next error is this :
WordPress database error: [Table 'wp_users' already exists]
CREATE TABLE wp_users ( ID bigint(20) unsigned NOT NULL auto_increment, user_login varchar(60) NOT NULL default '', user_pass varchar(255) NOT NULL default '', user_nicename varchar(50) NOT NULL default '', user_email varchar(100) NOT NULL default '', user_url varchar(100) NOT NULL default '', user_registered datetime NOT NULL default '0000-00-00 00:00:00', user_activation_key varchar(255) NOT NULL default '', user_status int(11) NOT NULL default '0', display_name varchar(250) NOT NULL default '', PRIMARY KEY (ID), KEY user_login_key (user_login), KEY user_nicename (user_nicename), KEY user_email (user_email) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
WordPress database error: [Table 'wp_usermeta' already exists]
CREATE TABLE wp_usermeta ( umeta_id bigint(20) unsigned NOT NULL auto_increment, user_id bigint(20) unsigned NOT NULL default '0', meta_key varchar(255) default NULL, meta_value longtext, PRIMARY KEY (umeta_id), KEY user_id (user_id), KEY meta_key (meta_key(191)) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
I tried everything and I can't solve the problem. what can I do? I don´t want to start from scratch with the webpages.
If the database already exists, most likely you have not edited the wp-config.php yet (using any text editor), where you have to insert your database data, like server, db name, db password, db user.
Here are some more details about this: https://wordpress.org/support/article/how-to-install-wordpress/#step-3-set-up-wp-config-php
Seems you are trying to CREATE tables in the DB which already exist, if you need the users already present on db, my suggestion is to manually backup the table (by dumping its), remove its (after the dump), and then re-insert them.
You can easly do that (directly on xampp) by using the PHPMYADMIN panel:
Open XAMPP Control Panel
Start Apache and Mysql Services and go to http://localhost/phpmyadmin/
Here you should be able to find the WordPress Database (in the menù at the left), open it and look for the table citizen by the logs.
export all of them (you should find the export button in the navigation bar upside)
Delete the table after exported.
Now the CREATE command should works fine. You can re-import the table exported at the point 3 after this procedure
I'm using Ubuntu 18.04 with Mysql and I'm trying to drop this SQL file:
CREATE TABLE IF NOT EXISTS `ammunition`
(
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`owner` text DEFAULT NULL,
`original_owner` text NOT NULL,
`hash` text NOT NULL,
`weapon_id` char(60) NOT NULL,
`count` int(11) NOT NULL DEFAULT 0,
`attach` text NOT NULL DEFAULT '[]',
PRIMARY KEY (`id`),
UNIQUE KEY `weapon_id` (`weapon_id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4;
I keep getting this error:
SQL ERROR (1101): BLOB, TEXT, GEOMETRY or JSON column attach can't have a default value
I've tried solving it, but the only suggestion I could find was to disable strict mode.
I disabled it permanently:
[mysqld]
sql_mode=""
And restarted the mysql service afterwards.
The temporary way without restart:
set global sql_mode='';
I'm still getting the error message, however. What am I doing wrong?
When you read the error message you see that TEXT..column attach can't have a default value.
To correct this, don't put a default value there.
If you do need a default value, use a VARCHAR column.
Disabling sql strict mode is is worst thing you can do. It will get you into trouble later.
FINAL: I'm closing this question because there is no way for me to reproduce the condition and trying to find a similar occurrence has proven fruitless.
A work-around using perl is being implemented to circumvent the failure that only some mysql installs are experiencing.
UPDATE: I've had another case and verified that this query is returning 'OFF'
SELECT `VARIABLE_VALUE` FROM `information_schema`.`GLOBAL_VARIABLES` WHERE `VARIABLE_NAME` LIKE 'INNODB_STRICT_MODE'
I'm having a hard time tracking down a query issue...
This is part of an update script that I made to install new tables and import data from old ones - if they exist. This is from a procedure that is installed, and then called, by the update script:
In this snippet, the table bot_inventories is created, then a check is performed to see if the old schema table exists. If it does, the old 'base' data is then copied to the new table.
The suspect query is the 'inner' if near the bottom:
CREATE TABLE `bot_inventories` (
`inventories_index` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`bot_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`slot_id` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`item_id` INT(11) UNSIGNED NULL DEFAULT '0',
`inst_charges` TINYINT(3) UNSIGNED DEFAULT 0,
`inst_color` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`inst_no_drop` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
`inst_custom_data` TEXT NULL,
`ornament_icon` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`ornament_id_file` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`ornament_hero_model` INT(11) NOT NULL DEFAULT '0',
`augment_1` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`augment_2` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`augment_3` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`augment_4` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`augment_5` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`augment_6` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`inventories_index`),
KEY `FK_bot_inventories_1` (`bot_id`),
CONSTRAINT `FK_bot_inventories_1` FOREIGN KEY (`bot_id`) REFERENCES `bot_data` (`bot_id`)
) ENGINE=InnoDB;
IF ((SELECT COUNT(*) FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'botinventory') > 0) THEN
INSERT INTO `bot_inventories` (
`inventories_index`,
`bot_id`,
`slot_id`,
`item_id`,
`inst_charges`,
`inst_color`,
`inst_no_drop`,
`augment_1`,
`augment_2`,
`augment_3`,
`augment_4`,
`augment_5`
)
SELECT
bi.`BotInventoryID`,
bi.`BotID`,
bi.`SlotID`,
bi.`ItemID`,
bi.`charges`,
bi.`color`,
bi.`instnodrop`,
bi.`augslot1`,
bi.`augslot2`,
bi.`augslot3`,
bi.`augslot4`,
bi.`augslot5`
FROM `botinventory` bi
INNER JOIN `bot_data` bd
ON bi.`BotID` = bd.`bot_id`;
IF ((SELECT COUNT(*) FROM `information_schema`.`COLUMNS` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'botinventory' AND `COLUMN_NAME` = 'augslot6') > 0) THEN
UPDATE `bot_inventories` bi
INNER JOIN `botinventory` bio
ON bi.`inventories_index` = bio.`BotInventoryID`
SET bi.`augment_6` = bio.`augslot6`
WHERE bi.`bot_id` = bio.`BotID`;
END IF;
RENAME TABLE `botinventory` TO `botinventory_old`;
END IF;
I have run this script myself dozens of times on both 'clean' and convertible (existing and populated botinventory table) databases with no problems.
The script executes properly on both MySQL v5.1.73 and MariaDB v10.0.22 (both win x86)
However, I've had two reported cases of failure surrounding the 'inner' if statement.
That check is in place to catch any 'customization' that may have been done by an admin and import their data.
The failed cases are reporting: "ERROR 1136 (21S01): Column count doesn't match value count at row 1"
I walked one of the admins through the manual installation of this update and found the problem to be with the 'if' query.
EDIT: It's acting like the query inside of the con check is firing off - defeating the purpose of the check itself (NULL is greater than '0'?)
(The walk-through admin is running MySQL v5.1.x as x86 on windows server 2012..the other is running MySQL v5.1.x as win (7?) x86.)
It seems to report that error when 'augslot6' does not exist - opposite behavior of what the check is in place to prevent.
I'm just not sure whether this is a syntax/methodology issue or an actual database code bug.
Searching for similar cases almost exclusively turns up results for column-entry count mis-matches, not why an if statement proves true with a false/null result...
Any suggestions?
EDIT: I am aware of what ANSI SQL code '21S01' indicates and how it could be interpreted to mean the missing augslot6 column. But, if so, why is the 'if' query proving 'true' when it should be 'false' on some systems?
EDIT: I wasn't able to perform the failing test myself as I don't have access to these systems.
I am trying to alter one of my InnoDB tables.
This is query:
ALTER TABLE `tf5h_assets`
ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `idx_asset_name` (`name`), ADD KEY `idx_lft_rgt` (`lft`,`rgt`), ADD KEY `idx_parent_id` (`parent_id`);
Error is:
#1114 - The table 'tf5h_assets' is full
I do not undesrtand how is it "full" when it's empty table i created from MySQL dump (structure, no data) file.
What's wierd is that i can alter it like this:
ALTER TABLE `tf5h_assets`
ADD PRIMARY KEY (`id`);
ALTER TABLE `tf5h_assets`
ADD UNIQUE KEY `idx_asset_name` (`name`);
ALTER TABLE `tf5h_assets`
ADD KEY `idx_lft_rgt` (`lft`,`rgt`);
ALTER TABLE `tf5h_assets`
ADD KEY `idx_parent_id` (`parent_id`);
and it does not throw that error.
What am i doing wrong?
This ALTER TABLE statements are from structure mysql dump file. Is there a way to split em like i did somehow when structure is exported so i dont have to do it manually?
I googles "table is full" error and this is what i did so far:
1) Checked for disk space - 80+ gigs of free space
2) Added to my.cnf :
innodb_file_per_table = 1
innodb_file_format = barracuda
and rebooted mysql server and created fresh db.
EDIT:
I solved my problem but i have no idea how to solve it for databases that i will not be able to export from Joomla.
Thing is, phpmyadmin is separating table creation from key creation like this:
CREATE TABLE IF NOT EXISTS `tf5h_assets` (
`id` int(10) unsigned NOT NULL COMMENT 'Primary Key',
`parent_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Nested set parent.',
`lft` int(11) NOT NULL DEFAULT '0' COMMENT 'Nested set lft.',
`rgt` int(11) NOT NULL DEFAULT '0' COMMENT 'Nested set rgt.',
`level` int(10) unsigned NOT NULL COMMENT 'The cached level in the nested tree.',
`name` varchar(50) NOT NULL COMMENT 'The unique name for the asset.\n',
`title` varchar(100) NOT NULL COMMENT 'The descriptive title for the asset.',
`rules` varchar(5120) NOT NULL COMMENT 'JSON encoded access control.'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=382 ;
and than later on:
ALTER TABLE `tf5h_assets`
ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `idx_asset_name` (`name`), ADD KEY `idx_lft_rgt` (`lft`,`rgt`), ADD KEY `idx_parent_id` (`parent_id`);
and later on:
ALTER TABLE `tf5h_assets`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary Key',AUTO_INCREMENT=382;
I managed to get my database up and running by using Joomla's backup / restore component (It's Joomla site). I opened up MySQL dump that component created and this is what i found in there:
CREATE TABLE `#__assets`
(`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary Key',
`parent_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Nested set parent.',
`lft` int(11) NOT NULL DEFAULT '0' COMMENT 'Nested set lft.',
`rgt` int(11) NOT NULL DEFAULT '0' COMMENT 'Nested set rgt.',
`level` int(10) unsigned NOT NULL COMMENT 'The cached level in the nested tree.',
`name` varchar(50) NOT NULL COMMENT 'The unique name for the asset.\n',
`title` varchar(100) NOT NULL COMMENT 'The descriptive title for the asset.',
`rules` varchar(5120) NOT NULL COMMENT 'JSON encoded access control.',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_asset_name` (`name`),
KEY `idx_lft_rgt` (`lft`,`rgt`),
KEY `idx_parent_id` (`parent_id`) )
ENGINE=InnoDB AUTO_INCREMENT=382 DEFAULT CHARSET=utf8;
Whole process is executed in one run, and it works fine.
Now, i have luck it's Joomla database. But what will i do when database wont be Joomla's? I have no idea. Is there a way to change how phpmyadmin stores dump? Would terminal access to mysql create different mysql dump that would create database in one go instead of using "ALTER"?
Ok so i still don't know what creates this problem except that it has something to do with how phpmyadmin exports databases and reimports them again.
And as i assumed in my original post that i will run into this problem with database that can not be exported trough Joomla component sooner or later, it happened...well...sooner.
Anyway, if you have console access to your mysql server you can deal with this by simply mysql dumping:
mysqldump -p NameOfDatabase > NameOfDumpFile.sql
Download dump file from server and you can import it trough phpmyadmin. It works like a charm. mysqldump creates databases in one query so there is no problem with assigning keys etc.
this is more like a how-to question about csv, excel, mysql files than a standard coding question. However I really would appreciat some help with this.
I have this predefined CSV format, that I need in order to import it to a database with Sequel Pro.
ID,"user_login","user_pass","user_nicename","user_email","user_url","user_registered","user_activation_key",user_status,"display_name"
1,"some_name","$P$BDMmGci3KAqNQwfPtgzfQTp8D3k7bC.","some_name","some.name#gmx.net","","2013-06-27 11:32:08","",0,"Some Name"
On the other hand I have an old database file looking like this …
CREATE TABLE `ezxsubscription` (
`id` int(11) NOT NULL auto_increment,
`version_status` int(11) NOT NULL default '0',
`subscriptionlist_id` int(11) default '0',
`email` varchar(255) default '',
`hash` varchar(255) default '',
`status` int(11) default '0',
`vip` int(11) default '0',
`last_active` int(11) NOT NULL default '0',
`output_format` varchar(255) default '',
`creator_id` int(11) NOT NULL default '0',
`created` int(11) NOT NULL default '0',
`confirmed` int(11) NOT NULL default '0',
`approved` int(11) NOT NULL default '0',
`removed` int(11) NOT NULL default '0',
`user_id` int(11) default '0',
`bounce_count` int(11) default '0',
PRIMARY KEY (`id`,`version_status`)
) TYPE=MyISAM;
--
-- Dumping data for table `ezxsubscription`
--
INSERT INTO `ezxsubscription` VALUES (454,1,5,'name#surname.com','31b6bde64e1282ba82d7d0c8ad6ebaa9',2,0,0,'2',1127,1142840848,0,1142840868,0,2633,0);
INSERT INTO `ezxsubscription` VALUES (1,1,5,'name.name#gmail.com','fff4b8d75ecdfad43ed8c89444939cfb',2,0,0,'2',10,1141956489,1141956489,1141956489,0,14,0);
…
The database has like 400 users in it that I couldn't sort by hand. I need to have the database file to be in the format of the predefined CSV above. Where the email-address should be the user_login and user_name. The rest of the old database like approved, removed or whatever can simply be disregarded. It's just about the user-login and the passwords.
Any clever idea on how to do so? The aim is to import all the old users of the old database to the new database (based on Wordpress).
I would really appreciate some tips or tricks.
Thank you in advance.
Matt
Update:
This is the old format of the ezxsubscription table.
"id","version_status","subscriptionlist_id","email","hash","status","vip","last_active","output_format","creator_id","created","confirmed","approved","removed","user_id","bounce_count"
1,1,5,"andreas#gmail.at","fff4b8d75ecdfad43ed8c89444939cfb",2,0,0,2,10,1141956489,1141956489,1141956489,0,14,0
All I wanna do now is convert this users to the new wordpress format:
"ID","user_login","user_pass","user_nicename","user_email","user_url","user_registered","user_activation_key","user_status","display_name"
1,"local","$P$BCf7QHr3rsp0YNZd7eMfYgncRZmR6j0","local","temp#local.dev","","2013-03-14 18:46:29","",0,"local"
I do even have problems understanding what the hash in the old db means.
All I wanna do is copy all existing old users to the new wordpress database so that I have the e-mail addresses and the passwords, so that they are able to login again.
So I want to make the old email the username of the new wordpress db. And the hash should probably be the new user_pass in wordpress. However I only hope that the hash is the password of the current login — I don't even know for sure.
Kind Regards,
Matt
Use SELECT ... INTO OUTFILE syntax to create a CSV file from your old table with a query like this
SELECT *
INTO OUTFILE '/path/to/your/file.csv'
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM
(
SELECT 'id', 'user_login', 'user_pass', 'user_nicename','user_email','user_url','user_registered','user_activation_key','user_status','display_name'
UNION ALL
SELECT id, email, hash, SUBSTRING_INDEX(email, '#', 1), email, '', created, '', status, SUBSTRING_INDEX(email, '#', 1)
FROM ezxsubscription
) q
Content of the created file:
"id","user_login","user_pass","user_nicename","user_email","user_url","user_registered","user_activation_key","user_status","display_name"
"454","name#surname.com","31b6bde64e1282ba82d7d0c8ad6ebaa9","name","name#surname.com","","1142840848","","2","name"
"1","name.name#gmail.com","fff4b8d75ecdfad43ed8c89444939cfb","name.name","name.name#gmail.com","","1141956489","","2","name.name"