{"id":15048385,"url":"https://github.com/github/proxysql","last_synced_at":"2025-10-04T10:30:44.399Z","repository":{"id":65974887,"uuid":"190556958","full_name":"github/proxysql","owner":"github","description":"High-performance MySQL proxy with a GPL license.","archived":true,"fork":true,"pushed_at":"2019-05-31T19:05:25.000Z","size":76298,"stargazers_count":16,"open_issues_count":0,"forks_count":13,"subscribers_count":3,"default_branch":"v2.0.5","last_synced_at":"2024-09-25T21:10:55.683Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.proxysql.com","language":"C++","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"sysown/proxysql","license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/github.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-06T09:45:42.000Z","updated_at":"2024-07-31T03:18:27.000Z","dependencies_parsed_at":"2023-02-19T18:15:26.845Z","dependency_job_id":null,"html_url":"https://github.com/github/proxysql","commit_stats":null,"previous_names":[],"tags_count":100,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Fproxysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Fproxysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Fproxysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Fproxysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/github","download_url":"https://codeload.github.com/github/proxysql/tar.gz/refs/heads/v2.0.5","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219876582,"owners_count":16554769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T21:11:16.076Z","updated_at":"2025-10-04T10:30:37.027Z","avatar_url":"https://github.com/github.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"Introduction\n============\n\nProxySQL is a high performance, high availability, protocol aware proxy for MySQL and forks (like Percona Server and MariaDB).\nAll the while getting the unlimited freedom that comes with a GPL license.\n\nIts development is driven by the lack of open source proxies that provide high performance.  \n\n\u003ca\u003e\u003cimg src=\"https://proxysql.com/assets/images/sm-share-default.png\" alt=\"ProxySQL\"\u003e\u003c/a\u003e\n\nUseful links\n===============\n\n- [Official website](http://www.proxysql.com/)\n- [Documentation](https://github.com/sysown/proxysql/wiki)\n- [Benchmarks and blog posts](http://www.proxysql.blogspot.com/)\n- [Forum](https://groups.google.com/forum/#!forum/proxysql/)\n- [Linkedin group](https://www.linkedin.com/groups/13581070/)\n\n\nGetting started\n===============\n\n### Installation\nReleased packages can be found here: https://github.com/sysown/proxysql/releases\n\nJust download a package and use your systems package manager to install it:\n```bash\nwget https://github.com/sysown/proxysql/releases/download/v1.4.9/proxysql_1.4.9-ubuntu16_amd64.deb\ndpkg -i proxysql_1.4.9-ubuntu16_amd64.deb\n```\n\nAlternatively you can also use the available repositories:\n\n#### Ubuntu / Debian:\n\nAdding repository:\n```bash\napt-get install -y lsb-release\nwget -O - 'http://repo.proxysql.com/ProxySQL/repo_pub_key' | apt-key add -\necho deb http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/$(lsb_release -sc)/ ./ \\\n| tee /etc/apt/sources.list.d/proxysql.list\n```\n\nInstalling:\n```bash\napt-get update\napt-get install proxysql OR apt-get install proxysql=version\n```\n\n#### Red Hat / CentOS:\n\nAdding repository:\n```bash\ncat \u003c\u003cEOF | tee /etc/yum.repos.d/proxysql.repo\n[proxysql_repo]\nname= ProxySQL YUM repository\nbaseurl=http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/centos/\\$releasever\ngpgcheck=1\ngpgkey=http://repo.proxysql.com/ProxySQL/repo_pub_key\nEOF\n```\n\nInstalling:\n```bash\nyum install proxysql OR yum install proxysql-version\n```\n\n### Service management\nOnce the software is installed, you can use the `service` command to control the process:  \n\n#### Starting ProxySQL:\n```bash\nservice proxysql start\n```\n#### Stopping ProxySQL:\n```bash\nservice proxysql stop\n```\n\nOr alternatively via the Admin interface:\n```\n$ mysql -u admin -padmin -h 127.0.0.1 -P6032 --prompt='Admin\u003e '\nWarning: Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 4\nServer version: 5.5.30 (ProxySQL Admin Module)\n\nCopyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nAdmin\u003e proxysql stop\n```\n\n#### Restarting ProxySQL:\n```bash\nservice proxysql restart\n```\n\nOr alternatively via the Admin interface:\n```\n$ mysql -u admin -padmin -h 127.0.0.1 -P6032 --prompt='Admin\u003e '\nWarning: Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 4\nServer version: 5.5.30 (ProxySQL Admin Module)\n\nCopyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nAdmin\u003e proxysql restart\n```\n\n#### Reinitializing ProxySQL from the config file (after first startup the DB file is used instead of the config file):\n```bash\nservice proxysql initial\n```\n\n### Upgrades\nJust install the new package and restart ProxySQL:\n```bash\nwget https://github.com/sysown/proxysql/releases/download/v1.4.9/proxysql_1.4.9-ubuntu16_amd64.deb\ndpkg -i proxysql_1.4.9-ubuntu16_amd64.deb\nservice proxysql restart\n```\n\n### How to check the ProxySQL version\n```bash\n$ proxysql --version\n```\n```bash\nProxySQL version v1.4.9-1.1, codename Truls\n```\nA debug version has `_DEBUG` in its version string.\nIt is slower than non-debug version, but easier to debug in case of failures.\n```bash\n$ proxysql --version\n```\n```bash\nMain init phase0 completed in 0.000146 secs.\nProxySQL version v1.4.9-1.1_DEBUG, codename Truls\n```\n\n### Configuring ProxySQL via the `admin interface`\n\nFirst of all, bear in mind that the best way to configure ProxySQL is through its admin interface. This lends itself to online configuration (without having to restart the proxy) via SQL queries to its admin database. It's an effective way to configure it both manually and in an automated fashion.\n\nAs a secondary way to configure it, we have the configuration file. \n\n#### Configuring ProxySQL through the admin interface\n\nTo log into the admin interface (with the default credentials) use a mysql client and connect using the following `admin` credentials locally on port (6032):\n```bash\n$ mysql -u admin -padmin -h 127.0.0.1 -P6032 --prompt='Admin\u003e '\nWarning: Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 4\nServer version: 5.5.30 (ProxySQL Admin Module)\n\nCopyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nAdmin\u003e\n```\n\nnote: If your MySQL client version is version 8.04 or higher add `--default-auth=mysql_native_password` to the above command to connect to the admin interface.\n\nOnce connected to the admin interface, you will have a list of databases and tables at your disposal that can be queried using the SQL language:\n```mysql\nAdmin\u003e SHOW DATABASES;\n+-----+---------+-------------------------------+\n| seq | name    | file                          |\n+-----+---------+-------------------------------+\n| 0   | main    |                               |\n| 2   | disk    | /var/lib/proxysql/proxysql.db |\n| 3   | stats   |                               |\n| 4   | monitor |                               |\n+-----+---------+-------------------------------+\n4 rows in set (0.00 sec)\n```\nThis will allow you to control the list of the backend servers, how traffic is routed to them, and other important settings (such as caching, access control, etc). Once you've made modifications to the in-memory data structure, you must load the new configuration to the runtime, or persist the new settings to disk (so that they are still there after a restart of the proxy). A detailed tutorial on how to configure ProxySQL through the Admin interface is available [here](https://github.com/sysown/proxysql/wiki/ProxySQL-Configuration).\n\n#### Configuring ProxySQL through the config file\n\nEven though the config file should only be regarded as a secondary way to configure the proxy, we must not discard its value as a valid way to bootstrap a fresh ProxySQL install.\n\nLet's quickly go over the main sections of the configuration file (this overview serves as a very high level overview of ProxySQL configuration).\n\nTop-level sections:\n* `admin_variables`: contains global variables that control the functionality of the admin interface.\n* `mysql_variables`: contains global variables that control the functionality for handling the incoming MySQL traffic.\n* `mysql_servers`: contains rows for the `mysql_servers` table from the admin interface. Basically, these define the backend servers towards which the incoming MySQL traffic is routed. Rows are encoded as per the `.cfg` file format, here is an example:\n\t\n\t```bash\n\tmysql_servers =\n\t(\n\t\t{\n\t\t\taddress=\"127.0.0.1\"\n\t\t\tport=3306\n\t\t\thostgroup=0\n\t\t\tmax_connections=200\n\t\t}\n\t)\n\t```\n* `mysql_users`: contains rows for the `mysql_users` table from the admin interface. Basically, these define the users which can connect to the proxy, and the users with which the proxy can connect to the backend servers. Rows are encoded as per the `.cfg` file format, here is an example:\n\t\n\t```bash\n\tmysql_users:\n\t(\n\t\t{\n\t\t\tusername = \"root\"\n\t\t\tpassword = \"root\"\n\t\t\tdefault_hostgroup = 0\n\t\t\tmax_connections=1000\n\t\t\tdefault_schema=\"information_schema\"\n\t\t\tactive = 1\n\t\t}\n\t)\n\t```\n* `mysql_query_rules`: contains rows for the `mysql_query_rules` table from the admin interface. Basically, these define the rules used to classify and route the incoming MySQL traffic, according to various criteria (patterns matched, user used to run the query, etc.). Rows are encoded as per the `.cfg` file format, here is an example (Note: the example is a very generic query routing rule and it is recommended to create specific rules for queries rather than using a generic rule such as this):\n\t\n\t```bash\n\tmysql_query_rules:\n\t(\n\t\t{\n\t\t\trule_id=1\n\t\t\tactive=1\n\t\t\tmatch_pattern=\"^SELECT .* FOR UPDATE$\"\n\t\t\tdestination_hostgroup=0\n\t\t\tapply=1\n\t\t},\n\t\t{\n\t\t\trule_id=2\n\t\t\tactive=1\n\t\t\tmatch_pattern=\"^SELECT\"\n\t\t\tdestination_hostgroup=1\n\t\t\tapply=1\n\t\t}\n\t)\n\t```\n* top-level configuration item: `datadir`, as a string, to point to the data dir.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithub%2Fproxysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgithub%2Fproxysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithub%2Fproxysql/lists"}