{"id":15730,"date":"2025-09-19T17:55:58","date_gmt":"2025-09-19T12:25:58","guid":{"rendered":"https:\/\/www.skynats.com\/?p=15730"},"modified":"2025-09-19T18:02:52","modified_gmt":"2025-09-19T12:32:52","slug":"how-to-install-and-configure-proxysql","status":"publish","type":"post","link":"https:\/\/www.skynats.com\/blog\/how-to-install-and-configure-proxysql\/","title":{"rendered":"How to install and configure ProxySQL"},"content":{"rendered":"\n<ul class=\"wp-block-list\">\n<li>\u00a0A powerful SQL proxy that sits between your application and MySQL servers<\/li>\n\n\n\n<li>\u00a0ProxySQL configuration is designed for high-performance query routing and connection handling<\/li>\n\n\n\n<li>Helps to balance database load across multiple servers<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-small-font-size\" id=\"h-for-ubuntu-debian\"><strong>For Ubuntu\/Debian:<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>apt-get update\napt-get install proxysql<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-small-font-size\" id=\"h-start-the-proxysql-service\"><strong>Start the ProxySQL service:<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl start proxysql\nsystemctl enable proxysql<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-small-font-size\"><strong>Access the Admin Interface<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use the <a href=\"https:\/\/www.mysql.com\/\" target=\"_blank\" rel=\"noopener\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-secondary-color\">MySQL<\/mark><\/a> client to connect to ProxySQL\u2019s admin interface:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u admin -padmin -h 127.0.0.1 -P6032 --prompt='ProxySQL Admin> '<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Default credentials is admin. Port 6032 is used for admin and&nbsp; 6033 is used for SQL traffic<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-small-font-size\"><strong>Add a MySQL Backend Server<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now let\u2019s add a backend MySQL server to ProxySQL:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>INSERT INTO mysql_servers (hostgroup_id, hostname, port, weight)\nVALUES (1, 'mysql-backend.example.com', 3306, 100);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Apply the configuration<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>LOAD MYSQL SERVERS TO RUNTIME;\nSAVE MYSQL SERVERS TO DISK;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-small-font-size\" id=\"h-check-if-the-server-was-added\"><strong>Check if the server was added:<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT * FROM mysql_servers;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-small-font-size\"><strong>Add a MySQL User<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Add a user that will connect through ProxySQL:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>INSERT INTO mysql_users (username, password, default_hostgroup)\nVALUES ('app_user', 'strong_password', 1);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">&#8212; Apply the configuration<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>LOAD MYSQL USERS TO RUNTIME;\nSAVE MYSQL USERS TO DISK;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-small-font-size\" id=\"h-make-sure-the-same-user-exists-on-the-backend-mysql-server\"><strong>Make sure the same user exists on the backend MySQL server<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE USER 'app_user'@'%' IDENTIFIED BY 'password';\nGRANT ALL PRIVILEGES ON your_database.* TO 'app_user'@'%';\nFLUSH PRIVILEGES;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-small-font-size\" id=\"h-test-the-mysql-connection-via-proxysql\"><strong>Test the MySQL Connection via ProxySQL<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use the MySQL client to test connecting through ProxySQL:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -h 127.0.0.1 -P6033 -u app_user -p<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You should be able to authenticate and start querying the backend database via ProxySQL.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Conclusion<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">ProxySQL offers a robust and flexible solution for managing MySQL traffic in environments where performance, scalability, and high availability are critical. By acting as a smart proxy, it simplifies backend management, balances load efficiently, and provides advanced features like query routing and failover handling.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you need expert assistance with ProxySQL configuration, Skynats is here to help. Our professional <a href=\"https:\/\/www.skynats.com\/linux-server-management\/\">Linux server management services<\/a> and <a href=\"https:\/\/www.skynats.com\/high-traffic-server-management\/\">high traffic server management<\/a> solutions ensure your databases and applications run smoothly, securely, and without downtime. Contact us today for 24\/7 support from experienced server experts.<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>For Ubuntu\/Debian: Start the ProxySQL service: Access the Admin Interface Use the MySQL client to connect to ProxySQL\u2019s admin interface: Default credentials is admin. Port 6032 is used for admin and&nbsp; 6033 is used for SQL traffic Add a MySQL Backend Server Now let\u2019s add a backend MySQL server to ProxySQL: Apply the configuration Check [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[1110,1113,1010,701,1111,1109,1112],"class_list":["post-15730","post","type-post","status-publish","format-standard","hentry","category-blog","tag-high-traffic-server-management","tag-install-proxysql","tag-linux-server-management-services","tag-mysql","tag-mysql-backend-server","tag-proxysql","tag-proxysql-service"],"_links":{"self":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/15730","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/comments?post=15730"}],"version-history":[{"count":4,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/15730\/revisions"}],"predecessor-version":[{"id":15737,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/15730\/revisions\/15737"}],"wp:attachment":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/media?parent=15730"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/categories?post=15730"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/tags?post=15730"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}