UPDATE mytable SET mycolumn= LTRIM(RTRIM(mycolumn));
works fine on trimming columns removing trailer spaces, but how can i adjust it to trim all column
Some years late, but might help others: This code trims all fields of a the table "your_table". Could be expanded to work on the whole database in the same way....
SET SESSION group_concat_max_len = 1000000;
select concat('update your_table set ',group_concat(concat('`',COLUMN_NAME, '` = trim(`',COLUMN_NAME,'`)')),';')
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'your_table'
into @trimcmd;
prepare s1 from @trimcmd;
execute s1;
DEALLOCATE PREPARE s1;