I have a Mac computer and want to connect to a mysql db of an Amazon Linux server.
In terminal I did:
sudo ssh -v -i "key_file.pem" -L 22:localhost:22 [email protected]
After that I could connect to the db on Amazon from Mac in MySQL Workbench with following settings:

However, when I try something like: "mysql -h localhost —-protocol=TCP -u root -p" or when I try in SQLalchemy:
engine = create_engine("mysql+mysqldb://root:password_mysql_amazon@localhost/db?host=localhost?port=3306")
I get an error: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")
So I switched localhost for 127.0.0.1:22 but then I couldn't find where to add my key_file.pem?
So how do I arrange connection in SQLalchemy to this server that needs to be accessed with a key-file via ssh? Or am going about this all wrong? Thanks!