我正在尝试将grafana与mysql一起使用。 MySql从wordpres获取数据。我可以使用grafana连接到MySql数据库,但是任何查询数据库的尝试都会导致下面列出的权限错误。有人知道我在做什么错吗?创建此帐户时,请确保FLUSH PRIVILEGES;
。
正在使用什么帐户?
mysql> SELECT USER(),CURRENT_USER();
+-------------------+-------------------+
| USER() | CURRENT_USER() |
+-------------------+-------------------+
| grafana@localhost | grafana@localhost |
+-------------------+-------------------+
1 row in set (0.00 sec)
该帐户拥有什么权限?
mysql> show grants for 'grafana'@'localhost';
+------------------------------------------------------------------------+
| Grants for grafana@localhost |
+------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'grafana'@'localhost' WITH GRANT OPTION |
+------------------------------------------------------------------------+
1 row in set (0.00 sec)
我可以从表格中选择吗?(是)
mysql> select * from wp_users;
+----+---------------+------------------------------------+---------------+---------------------------+----------+---------------------+-----------------------------------------------+-------------+---------------+
| ID | user_login | user_pass | user_nicename | user_email | user_url | user_registered | user_activation_key | user_status | display_name |
+----+---------------+------------------------------------+---------------+---------------------------+----------+---------------------+-----------------------------------------------+-------------+---------------+
| 1 | admin | ********************************** | admin | a.guy@place.com | | 2019-02-22 18:09:58 | | 0 | something |
+----+---------------+------------------------------------+---------------+---------------------------+----------+---------------------+-----------------------------------------------+-------------+---------------+
1 row in set (0.00 sec)
什么是我的mysql信息?
mysql> status
--------------
mysql Ver 14.14 Distrib 5.7.25, for Linux (x86_64) using EditLine wrapper
Connection id: 42787
Current database: information_schema
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.25-0ubuntu0.18.04.2 (Ubuntu)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: utf8
Client characterset: latin1
Conn. characterset: latin1
UNIX socket: /var/run/mysqld/mysqld.sock
Uptime: 43 days 2 hours 29 min 53 sec
Threads: 3 Questions: 3576291 Slow queries: 0 Opens: 1570 Flush tables: 1 Open tables: 692 Queries per second avg: 0.960
--------------
尝试在grafana中运行什么查询?
SELECT
user_registered,
user_login
FROM wp_users
我尝试了带;
和不带尾随-没有变化。
grafana通过该查询还给我什么?
Error 1142: SELECT command denied to user 'grafana'@'localhost' for table 'wp_users'
我意识到该帐户的权限过多,但是看到grafana认为该帐户没有足够的权限,目前,我正在尝试使其至少能够满足其需要。
答案 0 :(得分:0)
在此困扰了几个小时之后,我想到了看日志的概念。由于MySql默认情况下未启用日志,因此我更改了设置以启用日志并重新启动MySql。完成此操作后,一切正常。看来我要做的就是重启服务。
解决方案:
sudo service mysql restart