Documente Academic
Documente Profesional
Documente Cultură
Introduction to ODBC and MySQL Connector ODBC ODBC (Object Database Connectivity) is a
widely used database API (Application Programmers Interface) used for establishing brandindependent database connections. Assuming a database has a driver available for ODBC, that driver
will act like a broker between the ODBC client requesting some information and the database, making
it possible to get all kinds of disparate systems connected to each other via the ODBC service.
MySQL Connector ODBC is the ODBC driver available for the MySQL database, and can be
downloaded freely from MySQL.com. In this tutorial, I will show you how you can use MS Office
applications to connect via ODBC to a MySQL database, then download data from that source to the
application in use (here I will demo Excel and Access).
The software I will be using are the following, if you are using different versions of Windows or
Office, then your interface might differ slightly (but hopefully not too much!):
Windows 2000 Professional, Service Pack 3: this should come with Data Sources (ODBC) installed
by default.
Office 2003 Professional: As of writing, this is the latest version of Office, but an older version
should work just fine.
MySQL 4.1.3 Beta: This is the latest test release of 4.1x available, but again an older version should
be fine. On my test network, I have MySQL installed on a separate machine running on the Redhat 9
Linux operating system, but this could just as easily be running on Windows.
MySQL Connector ODBC 3.51: The latest production version of the MySQL ODBC driver.
The Different Roles of the MS Office User and the MySQL DBA
It is worth pointing out that in a real environment, it is unlikely that the person using Office to access
the data is also the DBA (Database Administrator) for the MySQL database. Generally, the MySQL
database will reside on a remote server, while the ODBC service and the MySQL connection driver will
be installed locally on a Windows workstation.
ODBC connections present a convenient method for non-database specialists to access live data,
without having to request that data on a case-by-case basis from DBAs. While this will free up some
work for the DBA, it is important that the DBA realises that ODBC requires a user account to access
the database, so an account will have to be set up. Generally this account will only require read-only
access to a limited set of tables within a single database, and therefore it is important that this is the
only access granted, and that no other data is viewable to the ODBC user for security reasons.
Granting table privileges from the MySQL console is beyond the scope of this tutorial, so I will assume
that a DBA has set up this account correctly. In my test environment, the MySQL database and ODBC
client are on separate machines that are networked together: redhat.soylent contains the MySQL
database running on Linux; while w2k2.soylent is acting as the Windows 2000 client with the MySQL
Connector/ODBC driver installed. For simplicity I will use the root account and a sample password
(but you should never do this in a live environment for security reasons, as the root user can see
everything on the database!).
Installing MySQL Connector ODBC 3.51
We will begin by installing the MySQL Connector ODBC package on w2k2.soylent. After
downloading the Windows executable file, double click on it and follow the onscreen instructions. It is
quite safe to choose all of the default options for this simple install. If you install it successfully, you
should see a confirmation screen similar to the one below:
Start Access, and create a new blank database on your hard drive.
Choose File -> Get External Data -> Import...
In the file type drop-down, choose ODBC Databases
Now is this new dialog box, click the Machine Data Source tab, and choose your DSN from the list.
Access will then display a list of tables from the database. Choose the one you want.
Access will now create a new table in the Access database for you, containing the field names and
data records from your MySQL database:
Conclusion
MySQL is a fine database, with rock-solid dependability and very fast query response times. However,
for those users that do not possess a degree in computer science, it is not exactly the most user-friendly
database around. Furthermore, MySQL has no built-in reporting tools, something that the MySQL
designers leave to the software developers who build systems around MySQL to worry about.
The MySQL Connector ODBC driver admirably bridges this gap to allow non-technical users to access
their data with a set of tools that they tend to be much more comfortable with; Microsoft Office.
Furthermore, the report building tools of Access and the chart building wizards of Excel are ideal for
building professional reports based on MySQL stored data in no time, with the bare minimum of
training required.
ODBC is a solid technology that has been around for a long time now, and it is one that is likely to
remain in future releases of Windows due to its wide user base. As long as the company behind the
MySQL database, MySQL AB, maintain the MySQL Connector ODBC project, then an increasing
amount of users are likely to migrate to this package due to its ease of use and implementation.