Changing Charset to utf8 for all the fields and tables in mysql How should I use the mysql and awk to change the charset for all the fields and tables for a specific database? I did not include username or password, so for sure it will not work. 

Should I run it as it is and wait or does it need to be modified to work with authentication?

mysql --database=dbname -B -N -e "SHOW TABLES" \
| awk '{print "SET foreign_key_checks = 0; ALTER TABLE", $1, "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; SET foreign_key_checks = 1; "}' \
| mysql --database=dbname &amp;
First backup the database. Sometimes character conversions can give unexpected results. 

I have had good success using these instructions:    

SELECT CONCAT('ALTER TABLE ',  table_name, ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;') INTO OUTFILE '/tmp/altertablesstatements.sql'
FROM
information_schema.tables
WHERE
    table_schema='&lt;database-name&gt;'
AND table_collation != 'utf8' 
GROUP BY table_name;


Add disable foreign_key_checks to first line of sql. 

echo 'SET foreign_key_checks = 0;' &gt;&gt; /tmp/altertablesstatements.sql


Import the changes

mysql DATABASE  &lt; /tmp/altertablesstatements.sql


Converting Columns

SELECT CONCAT(  'ALTER TABLE &lt;DATABASE&gt;.', table_name,  ' CHANGE ',COLUMN_NAME,'  ',COLUMN_NAME,' ',COLUMN_TYPE,' CHARACTER SET utf8 COLLATE utf8_general_ci',
IF(IS_NULLABLE='NO',' NOT NULL;',' NULL;')) INTO OUTFILE '/tmp/altercolumnsstatements.sql'
FROM information_schema.COLUMNS AS tb
WHERE TABLE_SCHEMA =  '&lt;DATABASE&gt;'
AND character_set_name != 'utf8';


Add disable foreign_key_checks to first line of sql. 

echo 'SET foreign_key_checks = 0;' &gt;&gt; /tmp/altercolumnsstatements.sql


Import the changes

mysql DATABASE  &lt; /tmp/altercolumnsstatements.sql


https://confluence.atlassian.com/jirakb/how-to-change-all-columns-and-tables-collation-to-utf8_bin-in-mysql-601456761.html