title: how to setup and configure mysql-proxy on ubuntu on amazon ec2
body: <p>i am trying to setup mysql-proxy on ubuntu on amazon ec2
  i have done following:</p>
  
  <pre><code>sudo apt-get install mysql-proxy --yes
  vi /etc/default/mysql-proxy
  </code></pre>
  
  <p>i put following content on "/etc/default/mysql-proxy"</p>
  
  <pre><code>ENABLED="true"
  OPTIONS="--proxy-lua-script=/usr/share/mysql-proxy/rw-splitting.lua
       --proxy-address=127.0.0.1:3306
       --proxy-backend-addresses=private_ip_of_another_ec2_db_server:3306,private_ip_of_another_ec2_db_server:3306"
  </code></pre>
  
  <p>also tied with "--proxy-address=private_ip_or_public_ip_of_proxy-server:3306 or 4040"
  and "--proxy-backend-addresses=public_ip_of_another_ec2_db_server:3306,public_ip_of_another_ec2_db_server:3306"</p>
  
  <p>after that i tried to connect proxy server from another pc using mysql like:</p>
  
  <pre><code>mysql -u some_user -pxxxxx -h proxy_server_ip
  or 
  mysql -u some_user -pxxxxx -h proxy_server_ip -P 4040
  </code></pre>
  
  <p>but its not working
  its showing error: </p>
  
  <pre><code>ERROR 2003 (HY000): Can't connect to MySQL server on 'ip' (10061)
  </code></pre>
  
  <p>i want to tell you can connect the db server remotely where i allowed remote connection to any host</p>
  
  <p>i also tried /etc/init.d/mysql-proxy start or /etc/init.d/mysql-proxy restart but no result</p>
  
  <p>just to inform you that /etc/init.d/mysql-proxy stop is showing failed</p>
  
  <p>can anyone please help me to setup and configure mysql-proxy on ubuntu</p>
  
  <p>===</p>
  
  <h1>Edit</h1>
  
  <p>i found some help from other question of stackoverflow and also according to a suggestion in the comments, have done following procedure. and it seems its working now.</p>
  
  <p>i installed mysql-client and mysql-server locally(on proxy server)
  then i tried to run mysql-proxy using following command:</p>
  
  <pre><code>mysql-proxy --proxy-backend-addresses=10.73.151.244:3306 --proxy-backend-addresses=10.73.198.7:3306 --proxy-address=:4040 --admin-username=root --admin-password=root --admin-lua-script=&gt;/usr/lib/mysql-proxy/lua/admin.lua
  </code></pre>
  
  <p>then i tried to connect remotely to the proxy server and its working.
  but it seems i need to run this command under screen because when i close the terminal proxy stops working.</p>
  
  <p>Can you please tell me that do i need to run this command under screen or is there any other way to make it alive all time?</p>