0

I manage to establish a connection to a remote mysql server with pycharm's database feature.

1. View > Tool Windows > Databases
2. Click on +
3. Navigate to SSH/SSL
4. Insert ssh details
5. Test connection

The test connection works with the below message:

DBMS: MySQL (ver. 8.0.21) Case sensitivity: plain=exact, delimited=exact Driver: MySQL Connector/J (ver. mysql-connector-java-8.0.21 (Revision: 33f65445a1bcc544eb0120491926484da168f199), JDBC4.2) Ping: 210 ms SSL: yes

Now that I am connected to the mysql database via ssh I should be able to connect and run queries via a python script like so:

config = {
        'user': 'jsadmin',
        'password': 'password',
        'host': 'localhost',
        'database': 'mmdb',
        'port': 3306,
        'raise_on_warnings': True,
    }
conn = mysql.connector.connect(**config)

The above is giving me an error:

mysql.connector.errors.ProgrammingError: 1045 (28000): Access denied for user 'jsadmin'@'localhost' (using password: YES)

Why is there this error If I can run queries with the above credentials from pycharm's database console?

Edit

even having the same version of the mysql-connector-python to mysql server still produced the same issue

The question is once I shh from pycharm's data source properties window, is the server ip now localhost from python code?

bcsta
  • 1,963
  • 3
  • 22
  • 61
  • Does this answer your question? [Accessing MySQL from Python 3: Access denied for user](https://stackoverflow.com/questions/32852163/accessing-mysql-from-python-3-access-denied-for-user) – olinox14 Jan 04 '21 at 14:45
  • still had same error – bcsta Jan 04 '21 at 15:00
  • as far as I know, the fact you registered a datasource in pycharm has nothing to do with the python code you may write, it only allows you to interact with the db trough pycharm UI – olinox14 Jan 04 '21 at 15:03

0 Answers0