简体   繁体   English

如何将 CSV 加载到在 Raspberry Pi2 上运行的 MariaDB 中的表中?

[英]How do I load CSVs into tables in MariaDB running on a Raspberry Pi2?

I've installed MariaDB on my Pi2, which is connected to my network.我在连接到我的网络的 Pi2 上安装了 MariaDB。 I can access the Pi directly, through ssh or even VNC.我可以通过 ssh 甚至 VNC 直接访问 Pi。 I can also connect to it using MySQL Workbench.我也可以使用 MySQL Workbench 连接到它。

I have CSVs (Fantasy Football stats) I'm trying like to load into a table in a database, both of which I've already created.我有 CSV(Fantasy Football stats)我想加载到我已经创建的数据库中的表中。

CREATE DATABASE stats;
USE stats;
CREATE TABLE ff2020(
    id INT NOT NULL AUTO_INCREMENT,
    PlayerName VARCHAR(255) NOT NULL,
    Team VARCHAR(255) NOT NULL,
    Position VARCHAR(255) NOT NULL,
    Age INTEGER,
    GamesPlayed INTEGER,
    GamesStarted INTEGER,
    Targets INTEGER,
    Receptions INTEGER,
    PassingYds INTEGER,
    PassingTDs INTEGER,
    PassingAtt INTEGER,
    RushingYds INTEGER,
    RushingTDs INTEGER,
    RushingAtt INTEGER,
    ReceivingYds INTEGER,
    ReceivingTDs INTEGER,
    FantasyPoints INTEGER,
    Interceptions INTEGER,
    Fumbles INTEGER,
    FumblesLost INTEGER,
    PRIMARY KEY (id)
);

I used WinSCP to transfer the files containing the CSVs from my computer to the RPi, and orginally put the file containing the CSVs right on the desktop.我使用 WinSCP 将包含 CSV 的文件从我的计算机传输到 RPi,然后将包含 CSV 的文件直接放在桌面上。

USE stats;
LOAD DATA INFILE '/home/pi/Desktop/CSVs for stats/data-master/yearly/2020.csv'
INTO TABLE ff2020
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '/n'
IGNORE 1 ROWS;

In response, I get the message: Error Code: 1045. Access denied for user 'marine'@'localhost' (using password: YES)作为回应,我收到消息: Error Code: 1045. Access denied for user 'marine'@'localhost' (using password: YES)

The user marine has all privileges, but the same thing happens using root .用户marine拥有所有权限,但使用root也会发生同样的事情。 I've seen other posts that mention changing:我看过其他提到改变的帖子:

LOAD DATA INFILE...

to

LOAD DATA LOCAL INFILE...

When I try that, I get the message: Error Code: 2068. LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.当我尝试这样做时,我收到消息: Error Code: 2068. LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.

I also saw someone talk about reversing all the slashes in the file path, but when I tried I didn't get any different results.我还看到有人谈论反转文件路径中的所有斜杠,但是当我尝试时,我没有得到任何不同的结果。

So, I'm assuming there's a problem where MariaDB can't see or access other files on the pi and I don't know how to remedy this.所以,我假设有一个问题 MariaDB 无法看到或访问 pi 上的其他文件,我不知道如何解决这个问题。 Do I need to do something more elaborate, like enable remote access to MariaDB, even though everything is on one device?我是否需要做一些更详细的事情,比如启用对 MariaDB 的远程访问,即使一切都在一台设备上?

Thanks.谢谢。

pass --local-infile when you login登录时传递 --local-infile

mysql -u[username] -p[password] --local-infile

then specifying LOAD DATA LOCAL INFILE... should do the trick然后指定LOAD DATA LOCAL INFILE...应该可以解决问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在几秒钟内创建大型CSV? - How do I create large CSVs in seconds? 如何通过循环将csv的负载导入不同的python数据帧? - How do I import a load of csvs into different python dataframes via a loop? 如何使用CSVProvider加载具有不同结构的csv? - How to load csvs with different structures using CSVProvider? 如何在SQL Server中添加两个CSV(分别为标头和内容)? - How do I add two CSVs (Header and Content seperatly) into SQL Server? 我如何比较在 java 中没有标题格式和数据差异的 csv - How do i compare csvs which don't have headers for format and data difference in java 如何确保D3在javascript运行之前完成加载多个CSV? - How do I ensure D3 finishes loading several CSVs before javascript runs? 如何使用bash处理包含Unicode(泰语)字符的CSV? - How do I manipulating CSVs containing unicode (Thai) characters using bash? 如何从具有不相关分支的嵌套 JSON 创建单独的数据帧或 CSV? - How do I create separate dataframes or CSVs from a nested JSON with unrelated branches? 将所有 CSV 从本地驱动器上的路径加载到 AzureSQL DB w/Auto Create Tables - Load all CSVs from path on local drive into AzureSQL DB w/Auto Create Tables 在 Python 中将文本表转换为 CSV - Converting Text Tables Into CSVs in Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM