Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

One of our employees created a Microsoft Access Database and have built a Joomla! module around it. It is currently running on a WAMP server, with an ODBC connection to the adb file. How can i create an ODBC connection on Ubuntu for the Access database? At this point, i'm open to having the DB live locally on my Ubuntu server, or on an SMB share somewhere. Moving it from Access to MySql has already been proposed. It may come down to that, but i'm really being pressured to find another option. Does anyone know if this is possible and how to accomplish it?

share|improve this question
2  
Hello this question maybe better placed in stackoverflow. –  lordqwerty Nov 16 '12 at 15:41
    
Thank you, i will post it there as well. I wasn't sure, since my question was more specific to Ubuntu, and less specific to the programming aspect. –  Danimal Nov 16 '12 at 16:29
    
Don't cross-post it, ask a mod to move it :) –  Nanne Nov 16 '12 at 20:49
add comment

3 Answers

Your options for replacing the JET database engine running purely in Linux are slim at best. Remember access files are just flat files, and it is a piece of software provided by Microsoft that actually parses and runs the SQL commands. Microsoft unsurprisingly does not provide a Linux port.

Mysql and PHP are a match made in heaven, so you might consider the switch. If the PHP code is good, the switch will be painless.

share|improve this answer
    
Thanks! The problem is that someone created the Access database, cuz that's what they knew how to do. I'm the only one who knows PHP, but it's not a part of my job so i was trying to avoid it. But i may have to be the one to convert it.... Thanks again! –  Danimal Nov 16 '12 at 21:00
    
Access JET SQL is pretty watered down, and anything it can do MySQL can do better. I don't know much about PHP database drivers, but the conversion should be as simple as changing out the driver, and tidying up the SQL statements to run on MySQL. –  Bailey S Nov 16 '12 at 21:26
add comment

You can move from MS Access to MSSQL or MySQL or PostgreSQL, but you'll have to move it somewhere if you want PHP under Linux to be able to read it.

There are cookbook recipes all over the place for accessing Jet databases from PHP, but they're red herrings - they all assume you're running PHP on a Windows machine with MS Access installed, and use the Windows-only ODBC driver for opening Jet ("access") files which is bundled with Access. No good to you on Linux.

share|improve this answer
add comment

Read this link:

Accessing Microsoft SQL Server from PHP on Ubuntu using PDO, ODBC and FreeTDS

https://secure.kitserve.org.uk/content/accessing-microsoft-sql-server-php-ubuntu-using-pdo-odbc-and-freetds

follow these instructions to access SQL Server databases from PHP on your Ubuntu server:

Install the packages freetds-bin, freetds-common, tdsodbc, odbcinst, php5-odbc and unixodbc. This provides the libraries you need.

Copy the contents of /usr/share/doc/freetds-common/examples/odbcinst.ini into /etc/odbcinst.ini. This registers the FreeTDS driver with the ODBC layer.

Restart your webserver to load the ODBC module into PHP.

That's it! You should now be up and running. Try testing the database connection with something like this:

<?php
try
{
$db = new PDO('odbc:Driver=FreeTDS; Server=hostname_or_ip; Port=port; Database=database_name; UID=username; PWD=password;');
}
catch(PDOException $exception)
{
die("Unable to open database.<br>Error message:<br><br>$exception.");
}
echo '<h1>Successfully connected!</h1>';
$query = 'SELECT * FROM table_name';
$statement = $db->prepare($query);
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_NUM);
?>
share|improve this answer
    
Thanks, this looks promising! As far as the FreeTDS is concerned, will Access DB's be treated the same as MSSql DB's? –  Danimal Nov 19 '12 at 16:42
1  
FreeTDS is for connecting to a Microsoft SQL Server instance, which is an entire database and server solution running on a Windows machine. It has no capability to read Access data files. –  Bailey S Nov 19 '12 at 23:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.