MYSQL can't add index to table - mysql

Currently, I have '246312' records. I am trying to add index to datetime field in my table, using this command:
ALTER TABLE `dateup`.`Message`
ADD INDEX `date_index` (`postedAt` DESC);
I am getting this error:
ERROR 2013: Lost connection to MySQL server during query
SQL Statement:
ALTER TABLE `dateup`.`Message`
ADD INDEX `date_index` (`postedAt` DESC)
ERROR: Error when running failback script. Details follow.
ERROR 2006: MySQL server has gone away
I have tried to set:
SET ##GLOBAL.wait_timeout=1999300;
SET ##GLOBAL.max_allowed_packet=1073741824;
but still I get this error.

i cant rebuild the database using InnoDB,
but dumping the table and import again solved this problem
thank you

Related

ERROR: ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=COPY/INPLACE

I have used mysqldump to create a table that is 12GB from MySQL 5.7 to MySQL 8.0.29. I want to add a column using ALTER TABLE documents ADD COLUMN meta_data json NULL, algorithm=instant; in the new table created in 8.0.29. When I run this I keep getting the error ERROR: ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=COPY/INPLACE.
When searching Google I can only find information about a bug that should have been fixed in 8.0.14 as can be seen here .
I do not have any fulltext index on my table and trying to add the column to the end of the list.
Anyone know why this is not working?

Getting "Channel number out of range" error when altering table using after keyword

I have a MariaDB table with some foreign keys and triggers. For some reason I'm getting an error when I try to alter it using the AFTER keyword.
If I run this:
ALTER TABLE `foo` ADD COLUMN baz VARCHAR(190) NULL DEFAULT NULL AFTER `bar`;
I get this error:
ERROR 1030 (HY000): Got error 44 "Channel number out of range" from storage engine InnoDB
Yet if I run this:
ALTER TABLE `foo` ADD COLUMN baz VARCHAR(190) NULL DEFAULT NULL;
It works but (as expected) doesn't organize the columns in the order I need.
Any idea how to get this to work using the column order I need?
Update:
I haven't figured out the issue yet but I did try making alterations with the AFTER keyword to other tables and it turns out the issue occurs specifically with this one table, other tables function properly.
The error was occurring because the MariaDB was running on a Windows filesystem shared via WSL into a Docker container (/mnt/c/Git/my_project).
To fix it, the entire container was moved into the WSL filesystem (~/my_project) and then the ALTER command with the AFTER keyword worked fine.

Why does MYSQL error when I try to add a foreign key?

I am trying to make a relational database in MYSQL.
Currently, I am making the foreign keys and connecting them to the parent table.
The problem is when I try to do this(in MYSQL workbench) MYSQL adds this line of code:
ADD INDEX `FK_party_coalitionparty_idx` (`partyId` ASC) VISIBLE;
After some research, I found out that it does this because when I delete or update the parent table, it is really handy when the child tables also delete or update the connected values(or columns).
The problem is when I run the foreign key code without the add index line it runs without trouble, but with it added (and I think I understand why it is good to have it added) it errors and does not want to execute the code to update my database.
When I try to execute the code in a SQL file it gives me the following error with the word VISIBLE:
VISIBLE is not valid at this position.
When I only try to delete the visible word, it cannot add my constraint (I think because you cannot put 2 times add below each other). I will include some screenshots and the message log to make my problem more clear.
Message log:
Operation failed: There was an error while applying the SQL script to the database.
Executing:
ALTER TABLE `testdatabase`.`coalitionparty`
ADD INDEX `FK_party_coalitionparty_idx` (`partyId` ASC) VISIBLE;
;
ALTER TABLE `testdatabase`.`coalitionparty`
ADD CONSTRAINT `FK_party_coalitionparty`
FOREIGN KEY (`partyId`)
REFERENCES `testdatabase`.`party` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE;
ERROR 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 2
SQL Statement:
ALTER TABLE `testdatabase`.`coalitionparty`
ADD INDEX `FK_party_coalitionparty_idx` (`partyId` ASC) VISIBLE
My SQL File (when I try to run the SQL code but not with the workbench menu:
SQL file with the error included at the bottom
The question:
How do I need to fix this problem, so that I am able to use cascade and I don't get the error?
Thanks in advance!
Mariadb has no VISIBLE
check the manual for more information
So you can only do
ALTER TABLE `coalitionparty`
ADD INDEX `FK_party_coalitionparty_idx` (`partyId` ASC) ;
or switch to MySsQL

Error 2013: lost connection to mariadb when adding full text index

I am using Maria DB 10.1.8 latest stable version available and i have dumped around 15 Million records into table more_bar_codes table. When i tried to alter table to add fulltext index onto one of its column, am getting error
2013: lost connection to mysql server during query.
The syntax used is:
Alter table more_bar_codes add fulltext index dl_full_text_bar_code (bar_code);
Any idea how to fix this one?
No timeout worked for me. One workaround is to create temp table like old table and add full text index and then copy data to it. That has resolved my issue.

mysql crashes when alter table

I am using mysql version 6.1.4 and windows 7
I have an empty table where I want to drop a column and a foreign key. When I try to apply the changes the workbench crashes and when I try to stop Mysql it returns a error
ERROR 2013: Lost connection to MySQL server during query
SQL Statement:
ALTER TABLE `teste_db`.`search_products`
DROP FOREIGN KEY `product_id_id_refs_id_aa2f4dab`
ERROR: Error when running failback script. Details follow.
ERROR 2006: MySQL server has gone away
I have looked around a lot and could not find any clue...
Thanks in advance for any help!
Please follow the steps , If you dont
If it is a MyISAM Table repair it first and check table .
Where as it is a empty table , check if any index present delete that,
Try then , if still not work
Please paste your table structure , Table Engine name.