MySQL mysqlimport:错误:1045,拒绝访问

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6837061/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 20:38:06  来源:igfitidea点击:

mysqlimport: Error: 1045, Access denied

mysqlmysql-error-1045mysqlimport

提问by Mike Conigliaro

Does anyone know why I get this error when running mysqlimport?

有谁知道为什么我在运行 mysqlimport 时会收到此错误?

mysqlimport -u someone -pwhatever --columns=a,b,c,d,e bar /var/tmp/baz.sql
mysqlimport: Error: 1045, Access denied for user 'someone'@'%' (using password: YES), when using table: baz

However...

然而...

mysql -u someone -pwhatever
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 199
Server version: 5.1.41-3ubuntu12.10 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show grants;
+------------------------------------------------------------------------------------------------------------+
| Grants for someone@%                                                                                   |
+------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'someone'@'%' IDENTIFIED BY PASSWORD '*BLAHBLAHBLAH' |
| GRANT ALL PRIVILEGES ON `bar`.* TO 'someone'@'%'                                          |
+------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

mysql>

回答by Omry Yadan

You can avoid the need for the extra privileges by using the --local parameter to mysqlimport:

您可以通过在 mysqlimport 中使用 --local 参数来避免对额外权限的需要:

--local, -L

           Read input files locally from the client host.

回答by Mike Conigliaro

OK, it turns out that the FILE privilege is a "global" privilege, which apparently means you can't selectively enable it on certain databases, tables. etc. That's why my previous grant statement on bar.* had no effect:

好的,事实证明 FILE 权限是一个“全局”权限,这显然意味着您不能在某些数据库、表上有选择地启用它。等等,这就是为什么我之前在 bar.* 上的授权声明没有效果:

GRANT ALL PRIVILEGES ON `bar`.* TO 'someone'@'%' 

You need to grant FILE privileges on *.*:

您需要授予 FILE 权限*.*

GRANT FILE ON *.* to 'someone'@'%';

Hope this helps someone.

希望这可以帮助某人。

回答by H.Rabiee

Some would instead opt for this command, skipping the extra FILE grant.

有些人会选择这个命令,跳过额外的 FILE 授权。

mysql -u username -p <yourdbname> < yourfile.sql

mysql -u username -p <yourdbname> < yourfile.sql

回答by Bilal

mysqlimport is a command-line interface to the LOAD DATA INFILE statement, for which you need the 'FILE' privilege (server level).

mysqlimport 是 LOAD DATA INFILE 语句的命令行界面,为此您需要“文件”权限(服务器级别)。

From LOAD DATA INFILE syntax:

LOAD DATA INFILE 语法

Also, to use LOAD DATA INFILE on server files, you must have the FILE privilege.