Skip to content

MySQL Proxy

Sebastian edited this page Aug 29, 2016 · 9 revisions

MySQL Proxy provides possibilities to log and rewrite SQL Querries. As the name suggests, it is used as a proxy between the application and the database. A good Tutorial and further techniques can be found here.

##MySQL Proxy and Enterprise Architect Follow these steps to use MySQL Proxy with Enterprise Architect (Tested with Version 12):

  1. Download the latest release of MySQL Proxy and extract the archive.
  2. Go into the bin Folder and create a file named code.lua - To get started, insert the following lines:

function read_query(packet) if string.byte(packet) == proxy.COM_QUERY then print(string.sub(packet, 2)) end end ``` This is a basic logging script that writes all querries to the console output.

  1. Launch MySQL-Proxy with the the following command:

mysql-proxy.exe --proxy-backend-addresses= --proxy-lua-script= ``` It is important to use the full path to the lua file. A relative path might not work!

  1. Create a new ODBC Datasource. If not specified, the TCP/IP is localhost, the port 4040. Use your login data and the destination database. Also enter the details specified here (Allow big results, Matched rows instead of affected rows).

  2. Launch Enterprise Architect. Create a new server connection (Connect to Server). Use Microsoft OLE DB Provider for ODBC Drivers similar to the official documentation. Use your new ODBC Source as data source name and enter your login information.

  3. Everything is set up and should work now.

###Connection String Another possibility to add the connection in Enterprise Architect is using a connection string like this:

<connection name> --- DBType=0;Connect=Provider=MSDASQL.1;Password=<password>;Persist Security Info=True;User ID=< username>;Data Source=<odbc source>;Initial Catalog=<table name>;LazyLoad=1;

###Problems and Issues There might be problems regarding the MySQL ODBC Version. Successfully tested with Version 5.03.04.00, Problems with Version 5.03.06.00.

Clone this wiki locally