Information Services Division


Using MySQL with ODBC

MySQL databases can be accessed from a PC running Windows using ODBC (Open Data Base Connection). (Note that this is currently only available to PCs within the UCL internet domain.) This allows applications such as Microsoft Access to exchange data with a database on the MySQL server. To enable this, MyODBC, the ODBC driver for MySQL, must be installed on your PC. This is already installed on the Staff WTS service, but if you need it on a stand-alone PC, you should download version 5.1 from the MySQL Web site and install it.

Before you can use ODBC, you have to set up a Data Source or DSN, which includes information about the database you want to access. This is done using the ODBC Data Source Administrator. If you have installed MyODBC on your own machine, this tool will be found in the Windows Control Panel. The name and location varies, depending on which version of Windows you are running. It may be called Data Sources (ODBC) or simply ODBC. If you don't see it in the main list of control panels, look in Administrative Tools. On Staff WTS, the tool can be launched from the Start menu: go to Programs -> Software A-D -> Data Sources (ODBC).

When you start the ODBC Data Source Administrator, you will see the following panel. With the User DSN tab selected, click on Add:


Select MySQL ODBC 5.1 Driver from the list of drivers, and click Finish:


Fill in the form with the Data Source name, the MySQL server name, and your database name, user name and password. (Replace "ccaajrl" in the following example with your own user name.) The Data Source name is your choice - it will be the name you will need to quote when using ODBC from applications such as Microsoft Access:


You can click Test to check that you have typed your user name and password correctly. When you click OK, the DSN will be created. On Staff WTS, this is saved permanently for you and will be there whenever you log in. To see how to use the DSN from Access, see Using MySQL from Microsoft Access.