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!