0

I am using mysql.connector from Python to access data from a MariaDB but for each select statement I get:

mysql.connector.errors.ProgrammingError: 1142 (42000): SELECT command denied to user 'testUser'@'localhost' for table [TABLENAME]

... but the rights should be there?

MariaDB [DB_NAME]> SHOW GRANTS FOR 'testUser';
+------------------------------------------------------------------------------------------------------------------+
| Grants for testUser@%                                                                                            |
+------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'testUser'@'%' IDENTIFIED BY PASSWORD '[PW AS HASH]' |
+------------------------------------------------------------------------------------------------------------------+

It used to work but then I played a round with permissions in order to write out a text file from the result of an sql query (directly in MariaDB) - no idea what I did wrong ... how can I fix this back to working?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
lordy
  • 610
  • 15
  • 30
  • If you provide`SELECT User, Host,FROM mysql.use output (as text) and the option file, we may reveal what the issue has been (see my comment son your answer below). – ComputerVersteher Dec 12 '19 at 04:22

1 Answers1

0

Strangely enough

grant all privileges on * to 'testUser'@'localhost' identified by '[PW]';

fixed it while

grant all on *.* to 'testUser'@'%' identified by '[PW]';

did not ...

lordy
  • 610
  • 15
  • 30
  • Not strange just 2 different user`'testUser'@'%'`is used if no specific user/machine combination is found. But you created`'testUser'@'localhost'`and connect from`localhost , so that user is used. If you connect from`1.2.3.4`the user `'testUser'@'%'is used, unless you have a user named``'testUser'@'%1.2.3.4` – ComputerVersteher Dec 11 '19 at 11:34
  • Ok maybe I was wrong and [this](https://stackoverflow.com/questions/10823854/using-for-host-when-creating-a-mysql-user) is the answer. Was some days ago since I knew that – ComputerVersteher Dec 11 '19 at 11:39