pythonmysqlmysql-clusterpercona-xtradb-clusterproxysql

How to connect to ProxySQL from application


I have Percona XtraDB Cluster running in 3 nodes (node1, node2, node3). I've configured ProxySQL in the 4th node (admin).

I have an python application code trying to access the cluster.

While connecting to 3306 port of node1, I'm able to connect.

import MySQLdb as mdb
db = mdb.connect(host="node1", port=3306,user="root", passwd="*****", db="percona")

In order to achieve load balancing, the application should point to the ProxySQL port 6032.

import MySQLdb as mdb
db = mdb.connect(host="admin", port=6032,user="admin", passwd="*****", db="percona")

While trying to connect, I'm getting the following error:

OperationalError: (1045, "ProxySQL Error: Access denied for user 'admin'@'' (using password: YES)")

I used the grant privilages command in the proxysql

grant all privileges on percona.* to 'admin'@'%' identified by password 'bullet';

Unfortunately, I got the following error,

ERROR 1045 (#2800): near "grant": syntax error

Correct me if I'm wrong.

Should I use some other configuration to connect to the Percona XtraDB Cluster?


Solution

  • Port 6032 is for the administrative CLI. Instead, you would instead want to connect to port 6033 which listens to all traffic and does load balancing towards the backend PXC nodes. Good luck!