How to solve UTF8 With Bom when restore mysql database

Jun 23, 2014 at 3:39 AM
Hello everyone. When i restore mysql database from dumb file(.sql) . I always had UTF8 with Bom although i read file by utf8 format and i also have SET NAMES is utf8 as well!.
I don't know how to solve this problem and i need some help from you. Please help me out this problem!

This is my code.
 using(TextReader reader = File.OpenText(path_to_file))
            {
                using (MySqlConnection conn = new MySqlConnection(ConnectionString))
                {
                    using (MySqlCommand cmd = new MySqlCommand())
                    {
                        using (MySqlBackup mb = new MySqlBackup(cmd))
                        {
                            cmd.Connection = conn;
                            conn.Open();
                            //mb.ImportInfo.DatabaseDefaultCharSet = "utf8";                        
                            //mb.ImportFromFile(path_to_file);
                            mb.ImportFromTextReader(reader);
                            conn.Close();
                        }
                    }
                }
            }
I using latest version of Mysqlbackup

Thanks you very much!
Coordinator
Jun 23, 2014 at 4:19 AM
You wish the file to be encoded in UTF8 without BOM, but the output file is encoded with UTF8 with BOM?
You don't want the output file has the line of "SET NAMES" or
You don't want the "SET NAMES" is set to UTF8?

Is this your problem?
Jun 23, 2014 at 4:33 AM
Thanks for reply!

Sorry because i don't explain well! I already have database on phpmyadmin and i export that database to dumb file(.sql) using export button on phpmyadmin window.
Anh then i use that .sql file to restore other database on linux hosting in c# platform(console app). Of cource i am using mysqlbakup! This is heade inside my dumb file:
-- phpMyAdmin SQL Dump
-- version 4.0.8
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Mar 18, 2014 at 03:16 PM
-- Server version: 5.5.32-cll
-- PHP Version: 5.3.17

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES UTF-8 */;
Hope receive reply from you! Thanks.
Jun 23, 2014 at 5:00 AM
Sorry for not clear!

My dumb sql with utf8 without bom but when i restore it have utf8 with bom in database! I wanna restore database with utf8 in dumb sql file!

Thanks for take a look at this thread!
Coordinator
Sep 4, 2014 at 1:36 AM
Try to create a sample database that creates the error at: http://www.freemysqlhosting.net/
give the connection string
then upload a sample C# project that creates the error at: https://mysqlbackupnet.codeplex.com/workitem/list/basic
So I can test it directly.