问题描述
小弟刚学mysql,就遇到了大麻烦,网上的帖子也给得不够详细,一直无法导入数据,急啊困难如下:现有一文件,名字:dir.des.scop.txt ,小弟不知道如何导入进mysql中.希望高手说明的时候能详细一点,包括建什么库,如何建,还有建什么表,如何建,小弟跪谢数据部分内容 # dir.des.scop.txt # SCOP release 1.69 (July 2005) [File format version 1.00]# http://scop.mrc-lmb.cam.ac.uk/scop/# Copyright (c) 1994-2005 the scop authors; see http://scop.mrc-lmb.cam.ac.uk/scop/lic/copy.html46456cla-All alpha proteins46457cfa.1-Globin-like46458sfa.1.1-Globin-like46459faa.1.1.1-Truncated hemoglobin46460dma.1.1.1-Protozoan/bacterial hemoglobin46461spa.1.1.1-Ciliate (Paramecium caudatum)14982pxa.1.1.1d1dlwa_1dlw A:100068pxa.1.1.1d1uvya_1uvy A:46462spa.1.1.1-Green alga (Chlamydomonas eugametos)14983pxa.1.1.1d1dlya_1dly A:100067pxa.1.1.1d1uvxa_1uvx A:81667spa.1.1.1-Cyanobacteria (Synechocystis sp.), pcc 6803105305pxa.1.1.1d1s69a_1s69 A:105306pxa.1.1.1d1s6aa_1s6a A:97827pxa.1.1.1d1rtxa_1rtx A:79572pxa.1.1.1d1mwba_1mwb A:63437spa.1.1.1-Mycobacterium tuberculosis, HbN105096pxa.1.1.1d1rtea_1rte A:105097pxa.1.1.1d1rteb_1rte B:62301pxa.1.1.1d1idra_1idr A:62302pxa.1.1.1d1idrb_1idr B:105283pxa.1.1.1d1s61a_1s61 A:105284pxa.1.1.1d1s61b_1s61 B:105260pxa.1.1.1d1s56a_1s56 A:105261pxa.1.1.1d1s56b_1s56 B:88965spa.1.1.1-Mycobacterium tuberculosis, HbO85673pxa.1.1.1d1ngka_1ngk A:85674pxa.1.1.1d1ngkb_1ngk B:85675pxa.1.1.1d1ngkc_1ngk C:85676pxa.1.1.1d1ngkd_1ngk D:85677pxa.1.1.1d1ngke_1ngk E:85678pxa.1.1.1d1ngkf_1ngk F:85679pxa.1.1.1d1ngkg_1ngk G:85680pxa.1.1.1d1ngkh_1ngk H:85681pxa.1.1.1d1ngki_1ngk I:85682pxa.1.1.1d1ngkj_1ngk J:85683pxa.1.1.1d1ngkk_1ngk K:85684pxa.1.1.1d1ngkl_1ngk L:74660faa.1.1.4-Nerve tissue mini-hemoglobin (neural globin)74661dma.1.1.4-Nerve tissue mini-hemoglobin (neural globin)74662spa.1.1.4-Milky ribbon-worm (Cerebratulus lacteus)72890pxa.1.1.4d1kr7a_1kr7 A:108201pxa.1.1.4d1v07a_1v07 A:46463faa.1.1.2-Globins46464dma.1.1.2-Hemoglobin I46465spa.1.1.2-Ark clam (Scapharca inaequivalvis)14984pxa.1.1.2d3sdha_3sdh A:14985pxa.1.1.2d3sdhb_3sdh B:14986pxa.1.1.2d3hbia_3hbi A:14987pxa.1.1.2d3hbib_3hbi B:67865pxa.1.1.2d1jzla_1jzl A:67866pxa.1.1.2d1jzlb_1jzl B:14988pxa.1.1.2d4sdha_4sdh A:14989pxa.1.1.2d4sdhb_4sdh B:14992pxa.1.1.2d5hbia_5hbi A:14993pxa.1.1.2d5hbib_5hbi B:14994pxa.1.1.2d7hbia_7hbi A:14995pxa.1.1.2d7hbib_7hbi B:14990pxa.1.1.2d4hbia_4hbi A:14991pxa.1.1.2d4hbib_4hbi B:14996pxa.1.1.2d1hbia_1hbi A:14997pxa.1.1.2d1hbib_1hbi B:14998px问题补充:mysql> use dirDatabase changedmysql> create table tt(id bigint,name varchar(20));Query OK, 0 rows affected (0.13 sec)mysql> insert into tt value(1,'1');Query OK, 1 row affected (0.05 sec)mysql> select * form tt;ERROR 1064 (42000): You have an error in your SQL syntax; check the manual thatcorresponds to your MySQL server version for the right syntax to use near 'formtt' at line 1mysql> select * from tt;+------+------+| id | name |+------+------+| 1 | 1 |+------+------+1 row in set (0.03 sec)mysql> load data infile 'dir.hie.scop.txt' into table tt;ERROR 1366 (HY000): Incorrect integer value: '# dir.hie.scop.txt ' for column 'id' at row 1lggege 麻烦您看下这个是什么情况问题补充:是否建表的时候要和导入的数据类型,数据数量对应呢?
解决方案
C:Documents and Settingslg>mysql -u rootWelcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 12 to server version: 5.0.27-communityType 'help;' or 'h' for help. Type 'c' to clear the buffer.mysql> create database test;Query OK, 1 row affected (0.02 sec)mysql> use test;Database changedmysql> create table tt(id bigint, name varchar(20));Query OK, 0 rows affected (0.01 sec)mysql> insert into tt values(1, '1');Query OK, 1 row affected (0.00 sec)mysql> select * from tt;+------+------+| id | name |+------+------+| 1 | 1 |+------+------+1 row in set (0.01 sec)mysql> select * into outfile 'tt.txt' from tt;Query OK, 1 row affected (0.00 sec)mysql> delete from tt;Query OK, 1 row affected (0.00 sec)mysql> select * from tt;Empty set (0.00 sec)mysql> load data infile 'tt.txt' into table tt;Query OK, 1 row affected (0.00 sec)Records: 1 Deleted: 0 Skipped: 0 Warnings: 0mysql> select * from tt;+------+------+| id | name |+------+------+| 1 | 1 |+------+------+1 row in set (0.00 sec)
解决方案二:
有sql文件的话在命令行下直接执行sql文件。 命令: . ***.sql
解决方案三:
创数据库mysql> create database test; 连接到这个数据库mysql> use test; 创表mysql> create table tt(id bigint, name varchar(20)); 插入数据mysql> insert into tt values(1, '1'); 导数据到某个文件里面,这个tt.txt会在你的 mysql目录datatest 下(test是数据库名).mysql> select * into outfile 'tt.txt' from tt; 从某个文件将数据导回到数据库的某个表.mysql> load data infile 'tt.txt' into table tt; 需要去了解下面这个语法, 因为中间还有什么REPLACE覆盖相同数据,IGNORE忽略相同数据的用法.LOAD DATA INFILE
解决方案四:
楼主,不要这样导,mysql不是这样导数据的,你有sql文件吗直接在mysql命令行source 你的sql文件的路径就好了