Jump to: navigation, search

Note: You are currently viewing documentation for Moodle 2.0. Up-to-date documentation for the latest stable version is available here: ODBC.

ODBC is an abbreviation for Open Database Connectivity, and is an interface to access databases via SQL queries. See warning when using ODBC and Moodle. Template:Not for production sites

How to install ODBC

Very brief summary process for creating connection to moodle database in Windows environment. CAUTION: ODBC can delete, edit and add data to a database. Do not use this on a production server unless you understand the risks to your Moodle site.

In Windows

1. Go to the Administrative Tools control panel, then the Data Sources (ODBC) panel.

  • Install MySQL ODBC Driver 3.51
  • Start settings control panel #admin tools/ Data Sources/ ODBC /
  • add new service/
  • select MySQL ODBC driver/
  • follow prompts for
    • User & password/
    • open access/
    • get external data/
    • point to MySQL ODBC connection

2. Configure one new System/User DSN (call it, for example "moodle"). Do not forget to enable these options if the driver asks for them:

  • ANSI NULLS Enabled = true
  • Quoted Identifiers Enabled = true

Moodle config.php changes

3. Your Moodle config.php should include lines like these:

$CFG->dbtype    = 'odbc_mssql';     // Note this is different to all the other configs on this page!
$CFG->dbhost    = 'moodle';         // Where this matches the Data source name you chose above
$CFG->dbname    = '';               // Keep it blank!!
$CFG->dbuser    = 'yourusername';   // I usually use the 'sa' account (dbowner perms are enough)
$CFG->dbpass    = 'yourpassword';
$CFG->dbpersist =  false;
$CFG->prefix    = 'mdl_';            //Prefix, you can change it, but NEVER leave it blank.

4. Install Moodle as usual. Good luck!

ODBC uses

ODBC can be used as an access tool to various databases such as MS-Access, dBase, DB2, Excel, and Text. Through these Call Level Interface (CLI) specifications of the SQL Access Group, the OBDC allows a neutral way of accessing the data stored in personal computers and various databases. It was first created by Microsoft and Simba Technologies. ODBC 1.0 was initially released in September 1992, and eventually became a part of the international SQL standard in 1995. Microsoft originally shipped the ODBCs as a set of DLLs and still today, ships the set with every copy of Microsoft Windows. Today, more and more operating systems such as UNIX and Apple are adopting the ODBC.

ODBC strengths

The strength of ODBC is that by providing a universal data access interface, it allows independent software companies and parties to not have to learn multiple application programming interfaces. To simply put, with ODBC, applications can simultaneously access, view, and modify database from numerous and quite diverse databases. This is because the ODBC "re-codes" the SQL queries so that it would be readable by the various different databases.

ODBC weaknesses

HODBC also has its drawbacks. As managing a huge number of ODBC clients can mean an immense amount of drivers and DLLs being run, this could lead to a system administration overhead. Nonetheless, this minor issue led to further uses of the ODBC server technology (or the "Multi-Tier ODBC Drivers") to alleviate the load. Also, as drivers are a key in ODBCs, some have raised the issue of the newer drivers' stability, as often many have shown to have bugs in them.

See also