[英]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.