Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
BASH MySQL-在';字段列表';_Mysql_Linux_Bash_Csv - Fatal编程技术网

BASH MySQL-在';字段列表';

BASH MySQL-在';字段列表';,mysql,linux,bash,csv,Mysql,Linux,Bash,Csv,我在Linux终端上使用sql cli创建了下表: DROP TABLE IF EXISTS `songs`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `songs` ( `track_id` varchar(19) NOT NULL, `title` text,

我在Linux终端上使用sql cli创建了下表:

DROP TABLE IF EXISTS `songs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;

CREATE TABLE `songs` (
      `track_id` varchar(19) NOT NULL,
      `title` text,
      `song_id` text,
      `release` text,
      `artist_id` text,
      `artist_mbid` text,
      `artist_name` text,
      `duration` double DEFAULT NULL,
      `artist_familiarity` double DEFAULT NULL,
      `artist_hotttnesss` double DEFAULT NULL,
      `year` int(11) DEFAULT NULL,
      PRIMARY KEY (`track_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
我正在执行一个bash脚本,该脚本将数据从本地CSV文件加载到数据库表
songs

nano importSQL.sh
#!/bin/bash

IFS=,
while read column1 column2 column3 column5 column6 column7 column8 column9 column10 column11
      do
        echo "INSERT INTO cost (column1, ... ,column11) VALUES ('$column1', '$column2', '$column3', '$column4', '$column5', '$column6', '$column7', '$column8', '$column9', '$column10', '$column11');"

    done < a.csv | mysql -u root -abc song_db;

有没有关于如何避免这种情况的帮助?

在表定义中,您有一个额外的
s
用于
artist\u hottness
。您不想这样做。这是在乞求SQL注入。MySQL必须读取CSV文件,您应该使用它。谢谢Abhik@Wintermute,我无法做到这一点,因为我无法提供从mysql cli到我的CSV的路径。不知道为什么会发现这是一个权限错误。整理好了!谢谢!
ERROR 1054 (42S22) at line 1: Unknown column 'artist_hotttness' in 'field list'