Maria DB 在没有 root 的情况下无法使用 ENGINE=CONNECT 删除 table
Maria DB Can't drop table with ENGINE=CONNECT without root
如主题所示,我可以以 root 身份在 Maria DB 中创建和删除 table,但我不能以普通用户身份删除 table。它仅在 tabel 引擎连接时发生。
作为根用户:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON test_database.* To 'user'@'localhost' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SHOW GRANTS FOR user@localhost;
+--------------------------------------------------------------------------------------------------------------+
| Grants for user@localhost |
+--------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'user'@'localhost' IDENTIFIED BY PASSWORD '*EE22D94139EAEE5486C30FBC352B12340EEF82F5' |
| GRANT ALL PRIVILEGES ON `test_database`.* TO 'user'@'localhost' |
+--------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
以普通用户身份从 root 帐户登录:
# mysql -u user -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 20120
Server version: 10.1.9-MariaDB MariaDB Server
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [test_database]> CREATE TABLE example (id INT, data VARCHAR(100));
Query OK, 0 rows affected (0.61 sec)
MariaDB [test_database]> DROP TABLE example;
Query OK, 0 rows affected (0.03 sec)
MariaDB [test_database]> CREATE TABLE odbc_test ENGINE=CONNECT TABLE_TYPE=ODBC tabname='sample_table' CONNECTION='DSN=mssql_test;UID=test_user;PWD=password';
Query OK, 0 rows affected (0.03 sec)
MariaDB [test_database]> DROP TABLE odbc_test;
ERROR 1045 (28000): Access denied for user 'user'@'localhost' (using password: YES)
MariaDB [test_database]> SHOW GRANTS;
+--------------------------------------------------------------------------------------------------------------+
| Grants for user@localhost |
+--------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'user'@'localhost' IDENTIFIED BY PASSWORD '*EE22D94139EAEE5486C30FBC352B12340EEF82F5' |
| GRANT ALL PRIVILEGES ON `test_database`.* TO 'user'@'localhost' |
+--------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
MariaDB [test_database]> select current_user;
+-----------------+
| current_user |
+-----------------+
| user@localhost |
+-----------------+
1 row in set (0.04 sec)
用户需要什么样的权限才能使用 engine=connect 删除 table?
- 更新1。像这样检查 csv 文件 link:
https://mariadb.com/kb/en/mariadb/connect-csv-and-fmt-table-types/
它以 root 身份运行,但作为拥有所有权限的用户,我什至无法创建 table。
MariaDB [test_database]> create table people (name char(12) not null, birth date not null date_format='DD/MM/YY', children smallint(2) not null) engine=CONNECT table_type=CSV file_name='test.csv' header=1 sep_char=';' quoted=1;
ERROR 1045 (28000): Access denied for user 'user'@'%' (using password: YES)
问题已解决
GRANT FILE ON *.* TO 'user'@'%';
这解决了我的问题:-)
GRANT FILE ON *.* TO 'user'@'%';
如主题所示,我可以以 root 身份在 Maria DB 中创建和删除 table,但我不能以普通用户身份删除 table。它仅在 tabel 引擎连接时发生。
作为根用户:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON test_database.* To 'user'@'localhost' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SHOW GRANTS FOR user@localhost;
+--------------------------------------------------------------------------------------------------------------+
| Grants for user@localhost |
+--------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'user'@'localhost' IDENTIFIED BY PASSWORD '*EE22D94139EAEE5486C30FBC352B12340EEF82F5' |
| GRANT ALL PRIVILEGES ON `test_database`.* TO 'user'@'localhost' |
+--------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
以普通用户身份从 root 帐户登录:
# mysql -u user -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 20120
Server version: 10.1.9-MariaDB MariaDB Server
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [test_database]> CREATE TABLE example (id INT, data VARCHAR(100));
Query OK, 0 rows affected (0.61 sec)
MariaDB [test_database]> DROP TABLE example;
Query OK, 0 rows affected (0.03 sec)
MariaDB [test_database]> CREATE TABLE odbc_test ENGINE=CONNECT TABLE_TYPE=ODBC tabname='sample_table' CONNECTION='DSN=mssql_test;UID=test_user;PWD=password';
Query OK, 0 rows affected (0.03 sec)
MariaDB [test_database]> DROP TABLE odbc_test;
ERROR 1045 (28000): Access denied for user 'user'@'localhost' (using password: YES)
MariaDB [test_database]> SHOW GRANTS;
+--------------------------------------------------------------------------------------------------------------+
| Grants for user@localhost |
+--------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'user'@'localhost' IDENTIFIED BY PASSWORD '*EE22D94139EAEE5486C30FBC352B12340EEF82F5' |
| GRANT ALL PRIVILEGES ON `test_database`.* TO 'user'@'localhost' |
+--------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
MariaDB [test_database]> select current_user;
+-----------------+
| current_user |
+-----------------+
| user@localhost |
+-----------------+
1 row in set (0.04 sec)
用户需要什么样的权限才能使用 engine=connect 删除 table?
- 更新1。像这样检查 csv 文件 link: https://mariadb.com/kb/en/mariadb/connect-csv-and-fmt-table-types/
它以 root 身份运行,但作为拥有所有权限的用户,我什至无法创建 table。
MariaDB [test_database]> create table people (name char(12) not null, birth date not null date_format='DD/MM/YY', children smallint(2) not null) engine=CONNECT table_type=CSV file_name='test.csv' header=1 sep_char=';' quoted=1;
ERROR 1045 (28000): Access denied for user 'user'@'%' (using password: YES)
问题已解决
GRANT FILE ON *.* TO 'user'@'%';
这解决了我的问题:-)
GRANT FILE ON *.* TO 'user'@'%';