SET @DBNAME = 'example';
-- requested charset
SET @CHSET = 'utf8mb4';
-- requested collation
SET @COLL = 'utf8mb4_general_ci';
-- DATABASE collation
SELECT CONCAT('ALTER DATABASE `',@DBNAME,'` CHARACTER SET ',@CHSET,' COLLATE ',@COLL,';') as _sql UNION ALL
-- TABLE