gpt4 book ai didi

mysql - 访问被拒绝错误,而我应该拥有 pythonanywhere.com 的所有权限

转载 作者:行者123 更新时间:2023-11-29 05:01:13 27 4
gpt4 key购买 nike

我正在学习 MySQL 并通过他们提供的控制台在 pythonanywhere.com 上使用它。

我能够创建一些模式,但是当我尝试将数据加载到数据库中时,我收到了拒绝访问错误。

我使用了这段代码:

LOAD DATA 
INFILE '/home/username/data.tsv'
INTO TABLE table
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n';

出现这个错误:

ERROR 1045 (28000): Access denied for user 'username'@'%' (using password: YES)

在谷歌搜索解决方案时,我遇到了其他(但类似的)错误命令,如下所示:

SELECT user, host FROM mysql.user 

错误如下:

ERROR 1142 (42000): SELECT command denied to user 'username'@'10.0.0.44' for table 'user'

谁能帮我解决这个问题/告诉我我做错了什么?

最佳答案

有一个help page在专门处理这个问题的 pythonanywhere.com 上。有两点需要牢记。

The newer versions of MySQL client block load data by default. You need to pass it in as a command line switch. If you open up a Bash console you can connect to the database manually like so:

mysql -h myusername.mysql.pythonanywhere-services.com -u myusername 'myusername$default' -p --local-infile=1

The MySQL command LOAD DATA INFILE "foo.csv" tries to load the contents of the file foo.csv on the computer where the database is running. On PythonAnywhere, the MySQL server is on a different computer to the one where your code runs, so your files aren't available. Instead, you need to tell the database to load the file from the computer where the MySQL client is running, by adding the extra keyword LOCAL:

LOAD DATA LOCAL INFILE "foo.csv"

关于mysql - 访问被拒绝错误,而我应该拥有 pythonanywhere.com 的所有权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58859091/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com