Wednesday, September 30, 2015

import csv excel to mysql sql server. Transfer database

current:

Note: No space No special char,  on column name, must remove any space on column name from the begin in Excel.
Otherwise datatables filter search will fail.

1) download excel, csv and open it.
2) remove any column that DO NOT Need, the less column, the faster query speed.
3)No space No special char,on column name, must remove any space on column name from the begin in Excel.

4)import excel into sql server.
5)Mysql work bench migration wizard to transfer from sql server to mysql.
     top menu > database >Migration wizard

      setting:  use schema as is.
         choose:  only one schema:...
      if existing, keep ......

Now sql server to mysql finished.
Next is export mysql to a file, transfer file to server and import file back to mysql(server)

6)


source :   mysql work bench,  top menu > server > data export.
   export to self-contained (single) file format (xxx.sql)
or :
export to dump project, each table will be separate file for selective restore.


target :  mysql work bench,  top menu > server > data import.
   import from single file format (xxx.sql),  create a new schema before import



++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++








old
==========================================================
import csv to mysql tips:

0)must use excel to open csv file, find any comma , replace comma with space
  because any extra comma will fail the import later.

   replace any (,) (") with space, because it will fail import


1)column title must be NO space, No special character, No "-",

2)Notpad++ open csv, menu > encode > convert to utf-8

3)mysql workbench, import table,

   change all field to Text type, because int, double type can fail the whole import



import to sql server,  use excel format.


--------------------------------------------------------------

















-------------------------------------------------
download and install

mysql for excel

http://dev.mysql.com/doc/mysql-for-excel/en/mysql-for-excel-install.html


open csv file in excel,  click  "Data" tab on top rainbow,  find and click mysql for excel button


select all data, click export to mysql.
Note to set a ID column as primary key.
2) add primary key to column, you should change the column name to "Id"

3).specify column option , click each header and edit the column name and data type below it.
such as currency type should be decimal(19,4) for large amount decimal(10,2) for regular use.
as well as other varchar(255).


or you can alter table after.
when finished, go to mysql workbench to alter the table,
such as currency type should be decimal(19,4) for large amount decimal(10,2) for regular use.
as well as other varchar(255).


No comments: