When I export in SQL as choose "Save as file", the
chosen character set is not mentioned in the exported
file. If I later import the exported file using the
mysql command-line client, the result depends on the
default character set on the client system (e.g.
specified using ~/.my.cnf).
This problem can be solved by adding e.g. "SET NAMES
utf8" to the exported file. To avoid problems with old
MySQL servers and other database servers, these can be
embedded in MySQLs "conditional comments", e.g.
/*!40101 SET NAMES utf8 */.
The attached patch adds SET NAMES xxx to the header of
the SQL export when the output character set is
supported by MySQL (not all character sets in the list
are). It also saves the previous setting in temporary
variables so that it can be restored at the end of the
file. The output is intended to be similar to that of