asSQL is just great. It’s an ActionScript 3.0 library for connecting AIR applications to MySQL databases and it works brilliantly – when it works! Recently i gave it a shot again after an utter failure the last time i tried it… The library seems to be a port of the Java implementation of connecting to MySQL (Connections, Statements, Fields, etc). It takes a little getting used to but it’s an excellent library and i highly recommend it.

Background

My development environment is Windows-based (against my wishes… not enough loot or motivation for a Mac, lack of Adobe software on Linux) but i make up for this by running a virtual Linux installation in my Windows environment and networking the two together. It actually works really well, and the process for setting this up can be found here. To cut a very long and boring story short, essentially i cannot use localhost as your server when using this architecture since i have my LAMPP stack running on my Linux environment, so my “local server” can only be accessed using the IP address of the virtual system.

This complicates things a bit when trying to use asSQL to connect to my MySQL installation, because MySQL gets all paranoid and won’t accept connections from a foreign IP address (the IP of my Windows machine on which my AIR app is running)… To get around this, all you have to do is create a new user in MySQL (i used phpMyAdmin), set the user’s hostname to the IP address of your remote system (i’ve explained how to do this below) and you’re ready to rock and roll!

Solution

The first thing you need to do is get the IP address of the remote system…

Windows: Open the command line, type ipconfig
Linux & Mac: Open the terminal, type ifconfig

In this example, my IP address is 192.168.56.1

I’ll be using phpMyAdmin to fix the problem.

  1. Open phpMyAdmin and click on the Privileges tab.
  2. Click Add a new User
  3. Enter any username you like, paste the IP address obtained in the Host field and put in a password
  4. Under the Database for user panel, leave it at None
  5. Under the Global privileges, you can Check All

That should sort it out… Remember, this is HIGHLY insecure and should only be used on development environments and NOT production environments.Vote in HexoSearch