2008
11.27

Using Command Line Interface to import a MySQL database.

Sometimes we don’t have a database management system(DBMS) in our server, so we need to use command line interface to CREATE and IMPORT a database.

Here are some notes:

-- Login to MySQL
debian:# mysql -u root -pPASSWORD

-- Create a utf8 encode database.
CREATE DATABASE DB_NAME DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

-- Use the utf8 connection collation
SET NAMES utf8;

-- Import a utf8 SQL file.
SOURCE filename-utf8.sql

-- or, after create the database, back to system, and use the "mysql" command.
debian:# mysql DB_NAME -u root -pPASSWORD < filename-utf8.sql --default-character-set=utf8

in other way, we also can set my.cnf

[client]
    default-character-set=utf8
[mysqld]
    default-character-set=utf8
    default-collation=utf8_general_ci

No Comment.

Add Your Comment
:D :-) :( :o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>