Error
SQL query:
CREATE TABLE `wp_commentmeta` (
`meta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`comment_id` bigint(20) unsigned NOT NULL DEFAULT '0',
`meta_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`meta_value` longtext COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`meta_id`),
KEY `comment_id` (`comment_id`),
KEY `meta_key` (`meta_key`(191))
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
MySQL said: Documentation
#1050 - Table 'wp_commentmeta' already exists
I came across this issue and found that even if you drop the wp_commentmeta table, you are likely to have issues with other tables like wp_comments, wp_links etc.
Hence, the solution is just to drop the whole database, re-create a fresh one and restore to that. To do this, login to mysql:
mysql -u databaseuser -p
and then run the following command on your database:
drop database wordpress_database;
create database wordpress_database;
quit;
I had a similar issue and had to drop all the tables. Not recommended for the faint of heart. Make sure you have at least two different types of backups.
The error you are getting is pretty self explanatory!
You may think about executing the following SQL-Statement:
DROP TABLE wp_commentmeta;
Related
I am trying to backup a database using mysqldump but I got this error:
Trying to backup MySQL database... mysqldump: Couldn't execute 'show create table `transaction_registry`':
Table 'mysql.transaction_registry' doesn't exist in engine (1932)
the problem first were with innodb_index_stats & innodb_table_stats and followed the instructions and worked well but got another problem
I tried from these 1 - 2, but still getting the same error, any ideas?
what I ended doing is like that:
Removed corrupted tables:
rm -rf /var/lib/mysql/mysql/transaction_registry.idb
Recreated the table:
CREATE TABLE transaction_registry (
transaction_id bigint(20) unsigned NOT NULL,
commit_id bigint(20) unsigned NOT NULL,
begin_timestamp timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000',
commit_timestamp timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000',
isolation_level enum('READ-UNCOMMITTED','READ-COMMITTED','REPEATABLE-READ','SERIALIZABLE') COLLATE utf8_bin NOT NULL, PRIMARY KEY (transaction_id),
UNIQUE KEY commit_id (commit_id), KEY begin_timestamp (begin_timestamp), KEY commit_timestamp (commit_timestamp,transaction_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0 ;
Ref: https://mariadb.com/kb/en/mysqltransaction_registry-table/
I created a script using MySqlWorkbench, at the top of the script there is this:
CREATE SCHEMA IF NOT EXISTS `contacts` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
USE `contacts` ;
when I import this script in PhpMyAdmin, I get:
SQL query:
CREATE TABLE `contact` (
`id` int(11) NOT NULL,
`name` varchar(45) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
MySQL said: Documentation
1046 - No database selected
Why the schema contacts isn't creating a new database?
Use CREATE TABLE contacts.contact
(not allowed to comment yet, so forced to use answer.)
I got MySQL 5.7.15. I already disable apparmor, checked file paths( they are right and full), secure_file_priv parameter is empty, max_allowed_packet is enough, I logged as root and definitely got all grants, I also started MySQL as root and grant all rights to files. What else can be wrong?
Here is example
insert into `photos`(id, photo) values (50,LOAD_FILE('/home/root/files/pathDB/files/50.jpg'));
Here is table code
drop table if exists `photos`;
CREATE TABLE `photos` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`photo` longblob NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
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.
What is the difference between drop table and --drop table in mysql
For example: I'm getting error if I use -- but in all other places of Magento they are using -- before drop.
--DROP TABLE IF EXISTS {$this->getTable('faq/dinkchika')};
CREATE TABLE IF NOT EXISTS {$this->getTable('faq/dinkchika')} (
`faq_id` int(11) NOT NULL AUTO_INCREMENT,
`faq_question` varchar(255) DEFAULT NULL,
`faq_answer` varchar(255) DEFAULT NULL,
PRIMARY KEY (`faq_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
A line that starts with -- and has a space after that, is treated as a comment until the end of line. It won't be executed.
You can read more about Mysql comment syntax here: http://dev.mysql.com/doc/refman/5.1/en/comments.html
use a white space after -- ,if you are not using whitespace after -- then it will not
count as comment.after whitespace your query will look like this.
-- DROP TABLE IF EXISTS {$this->getTable('faq/dinkchika')};
CREATE TABLE IF NOT EXISTS {$this->getTable('faq/dinkchika')} (
`faq_id` int(11) NOT NULL AUTO_INCREMENT,
`faq_question` varchar(255) DEFAULT NULL,
`faq_answer` varchar(255) DEFAULT NULL,
PRIMARY KEY (`faq_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
Or you may use #(Hash) as well and
Try this: Drop table IF EXISTS table_name;
And then continue with creating the table, as it will be guaranteed to no longer exist.
I hope it will help for you..