The example in this article tells you how MySQL can be used when importing SQL scripts from the command line. Share to everyone for your reference, specific as follows:
Open the script in the graphical Interface management tool MYSQL Query browser (scripts include building, building, adding data) and executing without any problems, but if you use the MySQL command-line tool to execute the library script, add the data if it contains Chinese, the data stored is garbled or???。。。
Workaround 1: In the MySQL installation directory to find My.ini, the [MySQL] under the default-character-set=latin1 changed to Default-character-set=utf8 , save, and then restart the MySQL service to successfully import from the command line. Disadvantage, because the deployment, you may not be able to configure the user's computer, then the method is useless ...
Workaround 2: Add a row of set character set UTF8 at the beginning of the database script file, add the default character set UTF8 after the library name, and add the default charset after the table) = UTF8, add a line set character set UTF8 before adding data.
Note: The MySQL version I use is 5.1.
Set character set UTF8;
Drop database if exists library name
CREATE DATABASE library name DEFAULT CHARACTER SET UTF8;
Use library name;
/*==============================================================*/
/* Table: Form name */
/*=============== ===============================================*/
drop table if exists table name;
CREATE TABLE table name (
PID int auto_increment,
pname nvarchar () null,
remark nvarchar (m) null,
constraint pk_position primary KEY (PID)
) DEFAULT Charset=utf8;
/*=====================================================*//
* Add Data/*
/*================================ =====================*/
set character set UTF8;
Insert Table name (Pname,remark) VALUES (' 1, ');
Insert Table name (Pname,remark) VALUES (' 2, ');
More information about MySQL interested readers can view the site topics: "MySQL Index operation skills Summary", "MySQL Log Operation skills Encyclopedia", "MySQL Transaction operation skills Summary", "MySQL stored process skills encyclopedia", "MySQL database lock related skills summary" and " MySQL common function Big Summary "
I hope this article will help you with the MySQL database meter.