访问被拒绝错误,而我应该拥有 pythonanywhere.com 的所有权限
Access denied ERROR while I should have all privileges on pythonanywhere.com
我正在学习 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'
谁能帮我解决this/tell我做错了什么?
pythonanywhere.com 上有一个 help page 专门处理这个问题。有两件事要记住。
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 上使用它。
我能够创建一些模式,但是当我尝试将数据加载到数据库中时,我收到了拒绝访问错误。
我使用了这个代码:
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'
谁能帮我解决this/tell我做错了什么?
pythonanywhere.com 上有一个 help page 专门处理这个问题。有两件事要记住。
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"