Already a customer?
Enter your username and password to access our management tools.
login: password:

Working With MySQL Databases

About MySQL

From http://www.mysql.com/why-mysql/:

The MySQL® database has become the world's most popular open source database because of its consistent fast performance, high reliability and ease of use. It's used on every continent -- Yes, even Antarctica! -- by individual Web developers as well as many of the world's largest and fastest-growing organizations to save time and money powering their high-volume Web sites, business-critical systems and packaged software -- including industry leaders such as Yahoo!, Alcatel-Lucent, Google, Nokia, YouTube, and Zappos.com.

Not only is MySQL the world's most popular open source database, it's also become the database of choice for a new generation of applications built on the LAMP stack (Linux, Apache, MySQL, PHP / Perl / Python.) MySQL runs on more than 20 platforms including Linux, Windows, OS/X, HP-UX, AIX, Netware, giving you the kind of flexibility that puts you in control.


Getting Started

As the above blurb suggests, MySQL can be connected to via a multitude of languages. We'll cover the two most popular ones, PHP, and Perl.

PHP

Now, Assuming your database username is 'yourdomain_com', your password is 'p@ssw0rd' and your database name is 'yourdomain_com_au', the following PHP snippet will connect to the MySQL server, select your database and do a very simple SELECT query:

$conn = mysql_connect('mysql.webinabox.net.au', 'yourdomain_com', 'p@ssw0rd');
mysql_select_db('yourdomain_com_au', $conn);

$query = "SELECT * FROM some_table";
$query = mysql_query($query);
while ($row = mysql_fetch_assoc($queryr)) {
print_r($row);
}

This is all pretty basic stuff, for more information, please see the PHP Website for more info.


Perl

use DBI;

my $dbuser = "yourdomain_com";
my $dbpass = "p@ssw0rd";
my $db = "yourdomain_com_au";
my $dbhost = "mysql";

my $dbh = DBI->connect("DBI:mysql:database=$db;host=$dbhost",
"$dbuser","$dbpass",
{'RaiseError' => 1 });

my $action = "SELECT * from table";
my $sth;
$sth = $dbh->prepare("$action");
$sth->execute() or die "DB error: $DBI::errstr";
while (my $row_ref = $sth->fetchrow_hashref) {
print "$row_ref->{'row'}\n";
}

More info can be found on the DBD::Mysql page