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

时间:2011-07-26 21:52:18

标签: mysql mysql-error-1045 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

...然而

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>

4 个答案:

答案 0 :(得分:27)

使用--local参数mysqlimport可以避免需要额外的权限:

--local, -L

           Read input files locally from the client host.

答案 1 :(得分:22)

好的,事实证明FILE特权是一个“全局”特权,这显然意味着你不能在某些数据库,表上有选择地启用它。这就是我之前关于bar。*的授权声明没有效果的原因:

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

您需要在*.*上授予FILE权限:

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

希望这有助于某人。

答案 2 :(得分:13)

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

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

答案 3 :(得分:5)

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

来自LOAD DATA INFILE syntax

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