<\/span><\/h4>\nFor reference, below is the step to configure one single ProxySQL to send traffic to ClickHouse, and use itself as a backend.<\/p>\n
Create ClickHouse user:<\/p>\n
INSERT INTO clickhouse_users (username,password) VALUES ('clicku','clickp');\r\nLOAD CLICKHOUSE USERS TO RUNTIME;\r\nSAVE CLICKHOUSE USERS TO DISK;<\/pre>\nCreate MySQL user (same as ClickHouse):<\/p>\n
INSERT INTO mysql_users(username,password) SELECT username, password FROM clickhouse_users;\r\nLOAD MYSQL USERS TO RUNTIME;\r\nSAVE MYSQL USERS TO DISK;<\/pre>\nConfigure ProxySQL itself as a backend for MySQL traffic:<\/p>\n
INSERT INTO mysql_servers(hostname,port) VALUES ('127.0.0.1',6090);\r\nSAVE MYSQL SERVERS TO DISK;\r\nLOAD MYSQL SERVERS TO RUNTIME;<\/pre>\nCreate a query rule for rewriting queries:<\/p>\n
INSERT INTO mysql_query_rules (active,match_pattern,replace_pattern,re_modifiers) VALUES \r\n(1,\"FROM_UNIXTIME\\(`created`, '%Y-%m'\\)\", 'substring(toString(toDate(created)),1,7)',\"CASELESS,GLOBAL\");\r\nLOAD MYSQL QUERY RULES TO RUNTIME;\r\nSAVE MYSQL QUERY RULES TO DISK;<\/pre>\nThis is a very simple example to demonstrate how to perform query rewrite from MySQL to ClickHouse using just one ProxySQL instance.\u00a0In a real world scenarios you will need to create more rules based on your own queries.<\/p>\n