When you execute GRANT SELECT ON store.catalog TO 'wordpress'@'%';
, mysqld wants to insert a row into the grant table mysql.tables_priv
. Here is mysql.tables_priv:
mysql> show create table mysql.tables_priv\G
*************************** 1. row ***************************
Table: tables_priv
Create Table: CREATE TABLE `tables_priv` (
`Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
`Db` char(64) COLLATE utf8_bin NOT NULL DEFAULT '',
`User` char(16) COLLATE utf8_bin NOT NULL DEFAULT '',
`Table_name` char(64) COLLATE utf8_bin NOT NULL DEFAULT '',
`Grantor` char(77) COLLATE utf8_bin NOT NULL DEFAULT '',
`Timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`Table_priv` set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') CHARACTER SET utf8 NOT NULL DEFAULT '',
`Column_priv` set('Select','Insert','Update','References') CHARACTER SET utf8 NOT NULL DEFAULT '',
PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`),
KEY `Grantor` (`Grantor`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Table privileges'
1 row in set (0.00 sec)
mysql>
Since you want to insert a row into mysql.table_priv
where user='wordpress' and host='%', there has to exist a row in mysql.user
where user='wordpress' and host='%'.
You also mentioned that you are using MySQL Workbench. You must be using 'root'@'localhost'
. That would usually have all rights and a password.
If you want to just allow anonymous SELECT against that table, first run this:
GRANT USAGE ON *.* TO 'wordpress'@'%';
This will place wordpress@'%'
into mysql.user
. Afterwards, GRANT SELECT ON store.catalog TO 'wordpress'@'%'
should run just fine.
You will have to see what other wordpress entries are in mysql.user
. This should show what SQL GRANT commands you need:
SELECT CONCAT('GRANT SELECT ON store.catalog TO ',userhost,';') GrantCommand
FROM
(
SELECT CONCAT('''',user,'''@''',host,'''') userhost
FROM mysql.user WHERE user='wordpress'
) A;
Are you running this test between RDS and MySQL workbench on your own machine?
The MySQL client (and MySQL workbench) are including the time it takes for RDS to return the value of "1" to your workstation (from my workstation on the other side of the world, the response from RDS US West takes 280ms).
If you try enabling profiling on the RDS service, you can see how long the query is really taking - it's completing on your RDS instance in fractions of a millisecond.
mysql> set profiling = 1;
Query OK, 0 rows affected (0.00 sec)
mysql> select 1;
1
1
1 row in set (0.27 sec)
mysql> show profiles;
Query_ID Duration Query
1 0.00016200 select 1
mysql> show profile for query 1;
Status Duration
starting 0.000052
checking permissions 0.000008
Opening tables 0.000012
...
executing 0.000013
end 0.000008
...
cleaning up 0.000003
12 rows in set (0.28 sec)
set profiling = 0;
Query OK, 0 rows affected (0.28 sec)
Best Answer
user()
function shows what have your client answered when server asks "Who are you?".Query shows that your client answers using IPv6 local address.
There is no such record in your
mysql.user
table. But server finds the record which client's information is matched to.current_user()
function shows what account was applied by server for the authentication based on the client's info.Simply tell your client that it must connect to server using IPv4 - in command line or in configuration file, or disable IPv6 somewhere - on the client, or on the server, or on the workstation. Or add one more user with grant privileges -
'root'@'::1'
(recommended).I don't know why your server cannot convert
'::1'
adddress to'localhost'
name. Maybe you have no proper record::1 localhost
in your HOSTS file?