當我使用utf8/utf8mb4編碼進行備份時,我的表查詢以無法識別的字符返回。你如何使用UTF8編碼mysqldump特定表格?
這裏是我正在使用C#備份命令:
"-u{0} -p{1} -c -e --default-character-set=utf8 dbname tablename"
輸出:
-- MySQL dump 10.13 Distrib 5.6.24, for Win32 (x86)
--
-- Host: localhost Database: dbname
-- ------------------------------------------------------
-- Server version 5.6.24
/*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */;
/*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */;
/*!40101 SET @[email protected]@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @[email protected]@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @[email protected]@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @[email protected]@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @[email protected]@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @[email protected]@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `tablename`
--
DROP TABLE IF EXISTS `tablename`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tablename` (
`Sno` int(11) NOT NULL DEFAULT '0',
`ShopItemcode` varchar(255) DEFAULT NULL,
`Itemname` varchar(255) DEFAULT NULL,
PRIMARY KEY (`Sno`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tablename`
--
LOCK TABLES `tablename` WRITE;
/*!40000 ALTER TABLE `tablename` DISABLE KEYS */;
INSERT INTO `tablename` VALUES (992,'JPBC20','ஜீனà¯à®¸à¯(பூடà¯à®•à®Ÿà¯)சி20'),(993,'JPBC22','ஜீனà¯à®¸à¯(பூடà¯à®•à®Ÿà¯)சி22'),(994,'JPBC24','ஜீனà¯à®¸à¯(பூடà¯à®•à®Ÿà¯)சி24');
但是,當我需要備份XAMPP意味着字符返回良好。
我寫了一個C#本地庫,你可以試試看。它是MySqlDump的替代方法:https://github.com/adriancs2/MySqlBackup.Net – mjb