I'm trying to use grafana with mysql. MySql is getting data from wordpres. I can connect to the MySql database with grafana but any attempt to query the database results in a permission error quoted below. Does anyone know what I'm doing wrong? I made sure to FLUSH PRIVILEGES; when creating this account.
What account is being used?
mysql> SELECT USER(),CURRENT_USER();
+-------------------+-------------------+
| USER() | CURRENT_USER() |
+-------------------+-------------------+
| grafana#localhost | grafana#localhost |
+-------------------+-------------------+
1 row in set (0.00 sec)
What permissions does the account have?
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)
Can I select from a table? (Yes)
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)
What is my mysql info?
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
--------------
What query am a trying to run in grafana?
SELECT
user_registered,
user_login
FROM wp_users
I tried with with and without a trailing ; - no change.
What does grafana give back to me with this query?
Error 1142: SELECT command denied to user 'grafana'#'localhost' for table 'wp_users'
I realize that this account has too many permissions, but seeing as grafana thinks it doesn't have enough, for now I'm trying to get it to work with at least more than it needs.
After being stumped by this for a few hours, the notion of looking at logs was suggested to me. Since MySql doesn't have logs enabled by default, I changed the settings to enable the logs and restarted MySql. After doing this everything worked fine. It seems all I had to do was to restart the service.
The solution:
sudo service mysql restart
Related
Stupid question maybe but for some reasons, i am unable to see my RDS mysql db instance after connecting via mysql from my ec2 instance. The EC2 and the RDS security groups have the 3306 port open between them, no issues. The database is already created as i can see it on the RDS console.
mysql -h RDS endpoint -P 3306 -u root -p
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| innodb |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
Regards,
Ochen
I have create a mysql database locally in the unix macos Mojave environment, when entering mysql and entering command
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| cms_blog |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
then when entering sequelpro I attempt to connect to 'cms_blog'
Host: 127.0.0.1
default root and password for mysql
This is the error I am seeing
I'm wondering if because the database has no tables I am seeing this error, or because sequelpro may be looking to a mamp mysql conf file rather than the homebrew mysql I am using via cli. Any information would be greatly appreciated.
I am creating a db in mysql for a java program.My program works well in my friends system.But I have some problem with my mysql.
The query is below:
mysql> create database sampledb;
Query OK, 1 row affected (0.00 sec)
mysql> use sampledb;
Database changed
mysql> create user zebronics identified by 'zebra123';
ERROR 1146 (42S02): Table 'mysql.user' doesn't exist
I cant create any user for my db.Please help??
My solution was to run
mysql_upgrade -u root
Scenario: I updated the MySQL version on my Mac with 'homebrew upgrade'. Afterwards, some stuff worked, but other commands raised the error described in the question.
Looks like something is messed up with your MySQL installation. The mysql.user table should definitely exist. Try running the command below on your server to create the tables in the database called mysql:
mysql_install_db
If that doesn't work, maybe the permissions on your MySQL data directory are messed up. Look at a "known good" installation as a reference for what the permissions should be.
You could also try re-installing MySQL completely.
Same issue here as lxxxvi describes. Running
mysql_upgrade -u root
allowed me to then successfully enter a password that
mysql_secure_installation
was waiting for.
Your database may be corrupt. Try to check if mysql.user exists:
use mysql;
select * from user;
If these are missing you can try recreating the tables by using
mysql_install_db
or you may have to clean (completely remove it) and reinstall MySQL.
show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| datapass_schema |
| mysql |
| test |
+--------------------+
4 rows in set (0.05 sec)
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables
-> ;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| event |
| func |
| general_log |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| host |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| servers |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
23 rows in set (0.00 sec)
mysql> create user m identified by 'm';
Query OK, 0 rows affected (0.02 sec)
check for the database mysql and table user as shown above if that dosent work, your mysql installation is not proper.
use the below command as mention in other post to install tables again
mysql_install_db
You can run the following query to check for the existance of the user table.
SELECT * FROM information_schema.TABLES
WHERE TABLE_NAME LIKE '%user%'
See if you can find a row with the following values in
mysql user BASE TABLE MyISAM
If you cant find this table look at the following link to rebuild the database How to recover/recreate mysql's default 'mysql' database
Try run mysqladmin reload, which is located in /usr/loca/mysql/bin/ on mac.
'Error Code: 1046'.
This error shows that the table does not exist may sometimes be caused by having selected a different database and running a query referring to another table. The results indicates
'No database selected Select the default DB to be used by double-clicking its name in the SCHEMAS list in the sidebar'.
Will solve the issue and it worked for me very well.
It sometime happens when you run the grant/ privileges query on an empty database
I've just installed MySQL Community server (5.5.8) on Mac OS X 10.6.6.
I've been following the rules for a secure install (assign password to root, delete anonymous accounts, etc), however, there is one user account which I can't DROP:
mysql> select host, user from mysql.user;
+--------------------------------+------+
| host | user |
+--------------------------------+------+
| 127.0.0.1 | root |
| ::1 | root |
| My-Computer-Hostname.local | |
| My-Computer-Hostname.local | root |
| localhost | root |
| localhost | web |
+--------------------------------+------+
6 rows in set (0.00 sec)
mysql> drop user ''#'My-Computer-Hostname.local';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> select host, user from mysql.user;
+--------------------------------+------+
| host | user |
+--------------------------------+------+
| 127.0.0.1 | root |
| ::1 | root |
| My-Computer-Hostname.local | |
| My-Computer-Hostname.local | root |
| localhost | root |
| localhost | web |
+--------------------------------+------+
6 rows in set (0.00 sec)
mysql>
As you can see, MySQL reports no errors when executing the DROP USER command, but doesn't actually delete the user!
I've tried also deleting the user from within phpMyAdmin (3.3.9) and that produced the same results (i.e. reported success, no error messages, user not deleted).
I've researched this and some people suggest that GRANT may be blocking the DROP USER command, however, the user has no GRANT privileges:
mysql> SHOW GRANTS FOR ''#'My-Computer-Hostname.local';
+-----------------------------------------------------------+
| Grants for #my-computer-hostname.local |
+-----------------------------------------------------------+
| GRANT USAGE ON *.* TO ''#'my-computer-hostname.local' |
+-----------------------------------------------------------+
1 row in set (0.00 sec)
mysql> REVOKE GRANT OPTION ON *.* FROM ''#'My-Computer-Hostname.local';
ERROR 1141 (42000): There is no such grant defined for user '' on host 'my-computer-hostname.local'
I tried dropping the user again after that but it didn't drop/delete the user either.
I've checked my MySQl error logs and there's nothing unusual in there.
The MySQL manual suggests that it is possible to delete all anonymous accounts, so why can't I delete this one?
Or, to delete just the anonymous one and not the root as well:
mysql> DELETE FROM mysql.user WHERE User='' AND Host='my-computer-hostname.local';
Worked for me on 5.1.57.
This is a known bug due to your uppercase characters: http://bugs.mysql.com/bug.php?id=62255
Use the suggestion from user douger as a workaround
You can still delete the records from the user table:
mysql> DELETE FROM user WHERE host='my-computer-hostname.local';
Query OK, 2 rows affected (0.00 sec)
This method was used prior to MySQL 4.1...
MySQL includes an anonymous user account that allows anyone to connect into the MySQL server without having a user account. This is meant only for testing, and should be removed before the database server is put into a production environment.
Run the following SQL script against the MySQL server to remove the anonymous user account:
DELETE FROM mysql.user WHERE User='';
After making changes to permissions/user accounts, make sure you flush the provilege tables using the following command:
FLUSH PRIVILEGES;
Is there a whoami-like function in mysql?
I'm connecting to the mysql command line from a remote host. I'm not sure if my ip address is resolving to a domain name or not. I would like to see something like
mysql> whoami;
+----------------------------------+
| User | Host |
+----------------------------------+
| username | resolved.hostname.com |
+----------------------------------+
1 row in set (0.00 sec)
or
mysql> whoami;
+------------------------+
| User | Host |
+------------------------+
| username | 22.66.88.44 |
+------------------------+
1 row in set (0.00 sec)
You can use the CURRENT_USER and USER functions as follows:
SELECT CURRENT_USER();
SELECT USER();
CURRENT_USER shows who you are authenticated as, while USER shows who you tried to authenticate as.
See the MySQL manual for more information.
If you are using mysql command line utility then try \s command:
mysql> \s
--------------
mysql Ver 14.12 Distrib 5.0.67, for suse-linux-gnu (i686) using readline 5.2
Connection id: 519
Current database:
Current user: admin#localhost
.........
Server version: 5.0.67 SUSE MySQL RPM
.........
Just do a...
select user,host from mysql.user;
Should show you what you want.