Proxying connection to MySQL without MySQL Proxy - mysql

MySQL Proxy sounds like the best option to proxy a connection to MySQL server in order to modify queries online except that it only supports scripts in Lua, AFAIK.
Is it possible to script MySQL Proxy behavior in languages other than Lua? Ideally, C, C++ or C#?
If not, how do I look through and amend the traffic between MySQL client and server (e.g., in C#) without fully implementing the MySQL client/server protocol?

Yes, it is possible to build mysql proxy in other languages.
Here are few reference implementations in java
https://github.com/MPjct/JMPjct
https://github.com/Flipkart/phantom-mysql-proxy
To check the traffic between Mysql client and server , you can print the following param.
Com_Query.loadFromPacket(packet).query

Related

MySQL version: 5.5.36 vulnerable?

I client of ours did a PCI scan on their site and came up with the following alert:
vulnerable MySQL version: 5.5.36---Risk Level High
Is this version of MySQL in fact more vulnerable than others? Do I need to update the version (which will affect all the sites on the server) or can I tell him otherwise?
If an external scan is detecting MySQL, you've got huge problems. You need to firewall that service immediately.
You should not have port 3306 open to the general public under any circumstances, especially not if you're trying to get PCI compliance.
Firewall this service completely. If other external servers need access to this, they should do so via a VPN or SSH tunnel. Where this isn't practical, you must employ IP whitelisting at the firewall level.
The threat is real, but it's only in the client:
CVE-2014-0001
That doesn't just mean the command-line client, but any client, such as the MySQL API via PHP, etc.
If your MySQL client library only connects to your server, then there's no threat, as long as your server isn't exploited.
Still, you're unlikely to pass a PCI audit until you update MySQL beyond that version. You should be able to update to the latest 5.5 easily.

Access MySQL via HTTP

Is there any working solution for MySQL to be able to request data directly via HTTP/jsonp way?
I need to provide ready SQL statement to the server.
Something with SQL-templates etc.
There is beta version of mysql 5.7 that does that
MySql experimental MySQL HTTP API
I am currently trying the following alternatives:
YOG-Sql Tunnel in PHP and
Others: (1) undergo writing some webservices (java - php - c), (2) use 'mysql proxy' or 'mysql tunnel' (3) Code everyhing in gcc and run a proxy as http.
Tried many, stayed with YogSQL Tunnel (lot easier) - BTW ALL THOSE DID NOT GAVE SAME REAL-TIME RESULTS AS EVERYTHING INSIDE THE SAME DATACENTER (2 servers) or a gigabit network (250k - 500k records/second). So, latency may be a killer on one's ubiquitous cloud computing.
No, there is no way to do this.
I tried NGINX http add-on modules
ngnix really rocks, on static html even amazon free was outstanding (1ms wait) on 3000 requests/sec. Specific SQL modules, whatsoever, may be memory-consumig if goes heavy loader.io.

How to integrate database into software

I am practicing writing an app which use MySQL to manipulating data.
My concern is if my client machine doesn't have have MySQL pre-installed, it's not be able to run my app, is it?. So is there anyway to embed the database server right into the app, or to run the app without the data server. I wonder how all the softwares out there manipulates data. It's not like we need to install some kind of database server before install the app.
MySQL is a client/server database engine, which means that you must install the client and server separately from each, and they communicate over some kind of network protocol.
If you want to deploy a stand-alone application, you are probably better off using a library like SQLite, which gives you as much of the functionality of a SQL database as you are likely to need in such an app, but instead operates on local files and doesn't require installation of a separate server.
You can embed MySQL in your application, see MySQL as an Embedded Database for details.
Your application could work with the remote database, when configuring database connection you should set your DB server IP address(host), port and login credentials. so in order to write application which is dealing with data manipulation, you need to connect to any database instant.
If you are working on client-server application, MySQL database may be accessed either by means of MySQL (this solution may be suitable for internal networks), or through some database-side service, which can provide some API and which can be accessed from client via some application-level protocol (for example, XML-RPC).
If you are working on client application, there are other database solution, which can be used in stand-alone software: SQLite, Derby. As an alternative to database approach, you may consider storing data in XML / YAML format.
I suggest to wrap db layer in you application witch simple interface provided for all operations performed on the database. In this way, you will not have to go into the details of the atomic operations on the database and through unified interface, you can create several different classes which will be responsible for access to different databases in the same way (the same interface). These classes should realize the interface and implement all necessary methods inside (for example ADO). Now your db layer can be visible in all program it the same way. Wrapped class can realize singleton desing pattern and can be used as one instance enywhere in your application. Universal class design (interface) gives you many benefits such as the possibility of substitution on another layer if necessary (switch to a totally different db).

how to connect mysql server on external server in j2me application

I have a hosting account at godaddy ruinning Linux. Is has MySQL. I am creating a J2ME application that runs on android and I was wondering if there is any simpler way to connect from j2me application to my MySQL server?
Is it required to install anything at my server? which I cannot do because of the shared account. Any way to just open the connection, update some data in the MySQL from j2me application?
It is quite simple. You just need to do HTTP application/x-url-form-encoded request on the midlet and set request property to HTTP.POST. Then stream form data as bytes. Receive those post variable using a server side language (i used PHP) like $_POST['var'] and in that server script write MySQL query like insert into .. VALUES.. etc.
I don't know if any DB drivers exist for J2ME. If you can't find them just make layer on the server and implement your own protocol for retrieving data via http or sockets

connecting java applet with remote(?) mysql server

I have a mysql database and an applet in some free hosting site. The applet needs to access that mysql database. How do I do that ? Is it possible to remote access mysql database from an applet? how ?
The applet will execute on the client browser.
Its doubtful/unlikely that your free hosting provider allows remote mysql connections.
So your best bet would be some sort of HTTP web service.
If you can use Java on the server then check out CXF.
If you can only use PHP then things are tougher but look at NuSOAP.
On your applet you can use CXF to consume the service.