0

I am new in MySQL. I also checked other questions related with this one I couldn't solve it.

This is my command:

C:\Users\username\temp\Excercise\RDSQuery>python handler.py

And this is result I got:

Traceback (most recent call last):
  File "handler.py", line 20, in <module>
    connection = pymysql.connect(endpoint, user=username,
  File "C:\Users\username\temp\Excercise\RDSQuery\pymysql\__init__.py", line 94, in Connect
    return Connection(*args, **kwargs)
  File "C:\Users\username\temp\Excercise\RDSQuery\pymysql\connections.py", line 327, in __init__
    self.connect()
  File "C:\Users\username\temp\Excercise\RDSQuery\pymysql\connections.py", line 588, in connect
    self._request_authentication()
  File "C:\Users\username\temp\Excercise\RDSQuery\pymysql\connections.py", line 853, in _request_authentication
    auth_packet = self._read_packet()
  File "C:\Users\username\temp\Excercise\RDSQuery\pymysql\connections.py", line 676, in _read_packet
    packet.raise_for_error()
  File "C:\Users\username\temp\Excercise\RDSQuery\pymysql\protocol.py", line 223, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "C:C:\Users\username\temp\Excercise\RDSQuery\pymysql\err.py", line 107, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1045, "Access denied for user 'admin'@'xx.153.63.4' (using password: YES)")

And this is my python code:

import pymysql
endpoint = 'myauroradb-instance-1.xxxxxxxxx.eu-central-1.rds.amazonaws.com'
username = 'admin'
password = '123456'
database_name = 'Transactions_Prod'

#Connection
connection = pymysql.connect(endpoint, user=username,
    passwd=password, db=database_name)

def handler():
    cursor = connection.cursor()
    cursor.execute('SELECT * from Transactions')

    rows = cursor.fetchall()

    for row in rows:
        print("{0} {1} {2}".format(row[0], row[1], row[2]))
        
handler()

I tried this solutions in MySQL Workbrench:

CREATE USER 'admin'@'xx.153.63.4' IDENTIFIED BY '123456';
drop user 'admin'@'xx.153.63.4';
flush privileges;
create user 'admin'@'xx.153.63.4' identified by '123456';
GRANT all privileges on Transactions_Prod.* to 'admin'@'xx.153.63.4' IDENTIFIED BY '123456' WITH GRANT OPTION;
SHOW GRANTS FOR 'admin'@'xx.153.63.4';

But I still got the same error when I run the file in cmd.

After the SHOW GRANTS FOR 'admin'@'xx.153.63.4'; I see this:

'GRANT USAGE ON *.* TO \'admin\'@\'xx.153.63.4\' IDENTIFIED BY PASSWORD'

I know it has been asked a lot in this platform but I couldn't solve it on my own, please help me..

Thanks a lot!

firefighter
  • 171
  • 1
  • 14
  • 1
    Please do not use irrelevant tags - otherwise, please explain how this is related to MySQL workbench or AWS. Also, please share your attempts to check or errors - have you tried connecting on any other way? – Nico Haase Oct 29 '20 at 15:28
  • Does this answer your question? [Why is a "GRANT USAGE" created the first time I grant a user privileges?](https://stackoverflow.com/questions/2126225/why-is-a-grant-usage-created-the-first-time-i-grant-a-user-privileges) – Nae Oct 29 '20 at 15:33
  • I tried to create and drop the user in MySQL workbench. I created the table in the MySQL workbench. It is related with AWS because in the end I will try to query from AWS. Maybe it can be better if I share which tutorial I am following: https://www.youtube.com/watch?v=vyLvmPkQZkI – firefighter Oct 29 '20 at 15:33
  • It looks like grants could not be given to the user. – Nae Oct 29 '20 at 15:34

0 Answers0