我一直在到处寻找答案,但我仍然没有找到解决方案。背景:我的计算机上运行了一个 MySQL Server 5.5,用于测试最终将加载到我公司的生产服务器中的数据。我在 MySQL Workbench 中创建了数据库,并在加载时对其进行了适当的编辑以适合我的数据。我的数据远非干净,所以在大多数情况下,我在我的字段中使用 VARCHAR,因为可以将一大堆随机的东西放入字段中。我尝试过更改多项内容,但我不再确定我所做的任何事情是否已解决甚至有助于消除问题。
我的代码:数据库创建:
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
SET NAMES utf8;
DROP SCHEMA IF EXISTS `mydb` ;
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
USE `mydb` ;
-- -----------------------------------------------------
-- Table `mydb`.`Customer_Account`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Customer_Account` ;
CREATE TABLE IF NOT EXISTS `mydb`.`Customer_Account` (
`idCustomer_Account` VARCHAR(20) NOT NULL,
`Name` VARCHAR(130) NOT NULL,
`Billing_Street` VARCHAR(150) NULL,
`Billing_City` VARCHAR(30) NULL,
`Billing_StateProvince` VARCHAR(25) NULL,
`Billing_PostalCode` VARCHAR(15) NULL,
`Billing_Country` VARCHAR(20) NULL,
`Location_Type` VARCHAR(15) NULL,
`Parent_ID` VARCHAR(20) NULL,
`Parent_Name` VARCHAR(130) NULL,
PRIMARY KEY (`idCustomer_Account`),
UNIQUE INDEX `idCustomer_Account_UNIQUE` (`idCustomer_Account` ASC))
ENGINE = InnoDB DEFAULT CHARSET=utf8;
'CONSTRAINT `Parent_ID`
FOREIGN KEY (`idCustomer_Account`)
REFERENCES `mydb`.`Customer_Account` (`idCustomer_Account`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)'
-- -----------------------------------------------------
-- Table `mydb`.`Customer_Address`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Customer_Address` ;
CREATE TABLE IF NOT EXISTS `mydb`.`Customer_Address` (
`idCustomer_Address` VARCHAR(20) NOT NULL,
`Name` VARCHAR(50) NOT NULL,
`Name_Int` INT,
`Address` VARCHAR(80) NULL,
`City` VARCHAR(30) NULL,
`State` VARCHAR(5) NULL,
`ZIP` VARCHAR(15) NULL,
`LinkedAccount_Name` VARCHAR(100) NULL,
`LinkedAccount_ID` VARCHAR(20) NULL,
`CADD` INT,
PRIMARY KEY (`idCustomer_Address`),
UNIQUE INDEX `idCustomer_Address_UNIQUE` (`idCustomer_Address` ASC))
ENGINE = InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `mydb`.`Contacts`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Contacts` ;
CREATE TABLE IF NOT EXISTS `mydb`.`Contacts` (
`idContacts` VARCHAR(20) NOT NULL,
`Name` VARCHAR(50) NOT NULL,
`Title` VARCHAR(130) NULL,
`Mailing_Street` VARCHAR(110) NULL,
`Mailing_City` VARCHAR(30) NULL,
`Mailing_State` VARCHAR(25) NULL,
`Mailing_PostalCode` VARCHAR(20) NULL,
`Phone` VARCHAR(50) NULL,
`Account_ID` VARCHAR(20) NULL,
`Account_Name` VARCHAR(100) NULL,
PRIMARY KEY (`idContacts`),
UNIQUE INDEX `idContacts_UNIQUE` (`idContacts` ASC))
ENGINE = InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `mydb`.`Contact_Details`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Contact_Details` ;
CREATE TABLE IF NOT EXISTS `mydb`.`Contact_Details` (
`idContact_Details` VARCHAR(20) NOT NULL,
`Salutation` VARCHAR(70) NULL,
`First_Name` VARCHAR(30) NULL,
`Last_Name` VARCHAR(50) NULL,
`Title` VARCHAR(130) NULL,
`Mailing_Street` VARCHAR(175) NULL,
`Mailing_City` VARCHAR(50) NULL,
`Mailing_StateProvince` VARCHAR(30) NULL,
`Mailing_PostalCode` VARCHAR(20) NULL,
`Mailing_Country` VARCHAR(25) NULL,
`Phone` VARCHAR(50) NULL,
`Mobile` VARCHAR(35) NULL,
`Fax` VARCHAR(45) NULL,
`Email` VARCHAR(75) NULL,
`Email_OptOut` VARCHAR(1) NULL,
`Account_Owner` VARCHAR(20) NULL,
`Account_Name` VARCHAR(125) NULL,
`Account_ID` VARCHAR(20) NOT NULL,
`Active` VARCHAR(2) NOT NULL,
PRIMARY KEY (`idContact_Details`),
UNIQUE INDEX `idContact_Details_UNIQUE` (`idContact_Details` ASC))
ENGINE = InnoDB DEFAULT CHARSET=utf8;
'INDEX `Account_ID_idx` (`Account_ID` ASC)'
-- -----------------------------------------------------
-- Table `mydb`.`WF1_SR_Accounts`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`WF1_SR_Accounts` ;
CREATE TABLE IF NOT EXISTS `mydb`.`WF1_SR_Accounts` (
`idWF1_SR_Accounts` VARCHAR(20) NOT NULL,
`Name` VARCHAR(125) NOT NULL,
`Billing_Street` VARCHAR(135) NULL,
`Billing_City` VARCHAR(50) NULL,
`Billing_State` VARCHAR(20) NULL,
`Billing_PostalCode` VARCHAR(20) NULL,
`Billing_Country` VARCHAR(25) NULL,
`Location_Type` VARCHAR(20) NULL,
`Parent_ID` VARCHAR(20) NULL,
`Parent_Name` VARCHAR(125) NULL,
`SR_Account?` VARCHAR(5) NULL,
`WF1_Account?` VARCHAR(5) NULL,
`WF1_AccountNum` VARCHAR(10) NULL,
`WF1_AccountStatus` VARCHAR(25) NULL,
`WF1_AccountCreated` VARCHAR(50) NULL,
`WF1_BU` VARCHAR(10) NULL,
`WF1_Collector` VARCHAR(20) NULL,
`WF1_CreditHold` VARCHAR(5) NULL,
`WF1_CreditLimit` VARCHAR(10) NULL,
`WF1_CreditRating` VARCHAR(15) NULL,
`WF1_DVP` VARCHAR(20) NULL,
`WF1_PaymentTerms` VARCHAR(20) NULL,
`WF1_RSD` VARCHAR(40) NULL,
`WF1_TerritoryName` VARCHAR(45) NULL,
`WF1_TerritoryNumber` VARCHAR(5) NULL,
`Select_` VARCHAR(5) NULL,
`New_Select` VARCHAR(5) NULL,
`CRMFusion_Use` VARCHAR(10) NULL,
`CRMFusion_Change` VARCHAR(10) NULL,
PRIMARY KEY (`idWF1_SR_Accounts`),
UNIQUE INDEX `idWF1_SR_Accounts_UNIQUE` (`idWF1_SR_Accounts` ASC))
ENGINE = InnoDB DEFAULT CHARSET=utf8;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
注意:我还在 SET NAMES、DEFUALT CHARSET 和 CHARACTER_SET_SERVER 中用 latin1 替换了 utf8,并尝试制作两种加密类型的 .txt 文件。
我也跑了
SHOW VARIABLES like 'char%';
这是我的结果:
Variable_name Value
character_set_client latin1
character_set_connection latin1
character_set_database utf8
character_set_filesystem binary
character_set_results latin1
character_set_server latin1
character_set_system utf8
character_sets_dir C:\Program Files\MySQL\MySQL Server 5.5\share\charsets\
注意:在某一时刻,除了文件系统和服务器之外的所有内容都是 utf8 并且它也不起作用。
我还更改了 excel 和 notepad++ 中的加密类型,但更改似乎没有帮助。