Operation not allowed when innodb_forced_recovery > 0 [SqlYog] - mysql

I have created a table using SQLyog. When i insert values into it, it pops up following error message:
Operation not allowed when innodb_forced_recovery > 0.
My table consist only four columns including one primary key.
Following is my create and insert queries:
CREATE TABLE `news` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`title` varchar(100) NOT NULL,
`slug` varchar(100) NOT NULL,
`descr` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1
insert into `test`.`news` (`title`, `slug`, `descr`)
values ('titleOne', 'slugOne', 'descOne')

This error is comes when MySQL is in Read only mode.
Edit file /etc/my.cnf.
And comment out following line
# innodb_force_recovery = 1
Apparently this setting causes innodb to become read-only. If you don't have access to /etc/my.cnf on shared hosting, ask your host to fix it for you. When it's commented out or non-existent in /etc/my.cnf, the it reverts to a default setting of 0.

This happens to me also but what i did was to change the SQL Engine during creatng the table from InnoDB to MyISAM
like in
ENGINE=innoDB to ENGINE=MyISAM
So if you have your database and want to upload it, open it with any editor and change the engine at the end of each table from innoDB to MyISAM.
this resolved the problem.

Related

Can't Execute SQL File Event After Disabling Strict Mode

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.

"MySQL Error Code 1114: The table is full" keeps showing up

I'm running MySQL 8.0.23 on Windows server 2019.
Two tables:
CREATE TABLE `tblp` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`datum` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
KEY `index_dat` (`datum`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
and
CREATE TABLE `tblpdet` (
`id` int unsigned NOT NULL,
`katbr` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`redid` int unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`redid`),
KEY `Index_2` (`id`),
KEY `idx_katbr` (`katbr`),
CONSTRAINT `FK_tblpdet_1` FOREIGN KEY (`id`) REFERENCES `tblp` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
Now, if I execute:
select katbr, min(date(datum))
from tblp p
join tblpdet d on p.id = d.id
group by katbr;
I get error
Error Code: 1114. The table 'd:\tmp#sql1e5c_18_1eb' is full
If I execute:
select katbr, min(redid)
from tblpdet
group by katbr;
then it works fine.
Result should return some 120.000 rows.
Here are global settings relevant to this issue:
> innodb_data_file_path=ibdata1:12M:autoextend
> innodb_buffer_pool_size=51539607552
Table tblp has some 5.800.000 rows, and tblpdet has some 43.000.000 rows.
Data folder of MySQL is on SSD (mirrored) drive with 800GB of free space.
Total RAM is 128GB;
Machine has 2 processors with total of 20 cores, running only MySQL (at the moment).
Everything I read is ending up with 'not enough disk space', or wrong configuration of innodg_data_file_path. Anybody help?
First post so be kind.
I have a similar issue (Error Code: 1114. The table '/tmp/#sql2cc_b_3e' is full) with selecting and joining large datasets with sort and group by. The issue is present in 8.0.24 but not 8.0.22 or prior.
I tested this by exporting the database out of 8.0.24 where I received the error and importing into 8.0.20 where the same query runs successfully. I then updated without changing any other settings to 8.0.24 and the same query fails. I have also done a fresh install of 8.0.24 and also receive the error there.

mysql Field 'col1' doesn't have a default value

I had db schema defined as below
CREATE TABLE `ATestTable` (
id bigint(20) NOT NULL AUTO_INCREMENT,
refId varchar(32) NOT NULL,
col1 text COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unique_keyy_refId` (`refId`)
) ENGINE=InnoDB AUTO_INCREMENT=123 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
when I have something like this
Insert into ATestTable (refId, col1) Values ('abc', 'def');
I got error Field 'col1' doesn't have a default value. I searched online this error should happens when there is no value specified for this NOT NULL column. But I do specified the value. I even tried the same insert script on my local db and it works. So is it a db server configuration thing?
I run show variables like '%sql_mode%' and the one which doesn't work is NO_ENGINE_SUBSTITUTION. My local db (which works) is giving me ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
There are two things you can try, in other to fix your issue
1) You can change the sql mode to match your local db mode by running this query
SET GLOBAL sql_mode = 'modes';
modes separated by comma's. Note that this will work if only you have administrative rights. If not use
SET SESSION sql_mode = 'modes';
which will affect only the current client.
2) Set a default value for Col1 (eg: empty text) and the trigger will update the value anyways
CREATE TABLE `ATestTable` (
id bigint(20) NOT NULL AUTO_INCREMENT,
refId varchar(32) NOT NULL,
col1 text COLLATE utf8_unicode_ci DEFAULT ' ' not.
NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unique_keyy_refId` (`refId`)
) ENGINE=InnoDB AUTO_INCREMENT=123 DEFAULT.
CHARSET=utf8 COLLATE=utf8_unicode_ci;

LOAD_FILE returns NULL even after using all hints

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;

Altering MySQL table gives 1114 table is full

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.