This guide will walk you through how to set up ODBC on a Mac to get data from the MariaDB server into Stata. Please feel free to write in the comments if you’re having any issues.
Install iODBC. Although Mac OS X comes with iODBC, it is not fully featured and may be out of date. I installed iODBC using the “mxkozzzz.dmg” file from the downloads page.
Install the MySQL ODBC Connector. I installed the ODBC drivers using the DMG archive. On the download page there is a link “no thanks, just start my download” so you don’t need to provide any contact information.
Open the “iODBC Data Source Administrator64” application.
- Initialize a new “User DSN” by clicking the “Add” button.
- Select the “MySQL ODBC 5.3 Unicode Driver”, click finish.
- Specify a “Data Source Name (DSN)”. For this walk through I’ll call mine “mydsn”.
Add the following key-value pairs using the “+” button:
server = rhrcssql01.hbs.edu database = as_cortellis user = amarder password = XXXXX
Be sure to fill in the appropriate database, user, and password values.
To make sure that your DSN is working, highlight your newly created user data source, press the “Test” button, and enter your user name and password. You should see the message “the connection DSN was tested successfully, and can be used at this time.”
Open Stata and issue the following commands:
set odbcdriver ansi odbc list odbc load , exec("SELECT * FROM mytable") dsn("mydsn")
Be sure to fill in appropriate “mytable” and “mydsn” values.
Final note, if you are connecting to the MariaDB server from off campus you need to connect to the VPN first.
I found this post from Stata helpful.
I also found this post from MySQL helpful.
This post from MariaDB explains why I decided to use the MySQL ODBC Connector (it’s compatible and it’s “easy” to install).