I tried to do this: https://serverfault.com/a/65572/603515
But I changed it slightly to target only the database I want to change.
mysql -B -N --host=localhost --user=root --password=secret \
-e "select CONCAT('alter table ',TABLE_SCHEMA,'.',
TABLE_NAME,' charset=utf8mb4_bin;')
from information_schema.TABLES WHERE TABLE_SCHEMA = 'usda_nndsr';
select CONCAT('alter table ',TABLE_SCHEMA,'.',TABLE_NAME,' alter column ',
COLUMN_NAME,' charset=utf8mb4_bin;')
from information_schema.COLUMNS WHERE TABLE_SCHEMA ='usda_nndsr';" |
mysql --host=localhost --user=root --password=secret
but it's telling me:
mysql: mysql: [Warning] Using a password on the command line interface can be insecure.[Warning] Using a password on the command line interface can be insecure.
ERROR 1115 (42000) at line 1: Unknown character set: 'utf8mb4_bin'
I want utf8mb4_bin
because I heard MySQL utf8 is not real utf8 using only 3 bytes.
How can I edit my query or command to make the change. Currently it is the default swedish collation.
MySQL version:
$ mysql -V
mysql Ver 14.14 Distrib 5.7.32, for Linux (x86_64) using EditLine wrapper