Database.MySQL.connect() This page was last modified over 30 day(s) ago and has 3 comment(s)


Back to Database.MySQL Class Summary

Availability
Windows, Mac OSX, Linux

Usage
mdm.Database.MySQL.connect(host:String, port:String, compression:Boolean, userName:String, password:String, databaseName:String):Boolean

Parameters
host:String - Name of MySQL server

port:String - Port number on which MySQL listens for connections

compression:Boolean - Specifies whether or not compression is to be used for client-server communication

username:String - Username

password:String - Password

databaseName:String - Name of MySQL database

Returns
A Boolean

Description
Opens a connection to a MySQL database. Returns a boolean value indicating connection success.

Notes
The 'host' parameter can be DNS like "localhost" or IP "127.0.0.1".

The 'port' parameter, if left as empty string will default to 3306.

Example Code
var isConnected:Boolean = mdm.Database.MySQL.connect("localhost", "3306", true, "root", "", "test");

mdm.Database.MySQL Class Example Downloads
No Example Downloads Available


User Comment by xprdq on 5th February 2010 - 00:39
Is it possible to connect to a remote SQL host? If so, what would the 'host' parameter look like to do that? (I want to write an app to run from my desktop that will display info from a table on my website)

User Comment by xprdq on 5th February 2010 - 01:34
Is it possible to connect to a remote SQL host? If so, what would the 'host' parameter look like to do that? (I want to write an app to run from my desktop that will display info from a table on my website)

User Comment by DEVNEB on 7th June 2010 - 20:55
Yes, it is possible to connect to a remot MySQL Host.

The "host" paramater is provided by your hosting company. It could be the domain name of your website, an IP address or a different host (look in your hosting account's control panel or in the doc provided by your hosting company).

Generally, you will create in MySQL (or via PhMyAdmin or your hosting account's control panel) a new user wich will be allowed to connect from outside of you server (ex: mysqluser@%, where % means anywhere... You can be more specific and allow only your home IP like this "mysqluser@85.92.69.194").

Finally, the port configuration will also be given with the host information, 3306 is set by default but it will depends on your hosting server configuration.

Registered Users must be logged in to 'MyAccount' to add a Comment - Log In Here
  After Logging In, Click Here to Refresh This Page