Mysql for excel for mac

Ever tried to access a mySQL database within Excel on macOS using the ODBC driver (64bit)? – I tried and failed. Here is my way out of the mess.

Using a Windows environment it is so pretty simple: Download ODBC driver for Windows from the mySQL Webpage, install it, open the system control -> ODBC configuration, add a DSN using input fields, test it. Next start Excel, external datasource, select DSN and voila: full access to the database.

I’ll spare you all the details of failure and just list a few of the error messages on the way to success:

The installation failed. The Installer encountered an error the caused the installation to fail. Contact the software manufacturer for assistance.

Error message if you want to install the MySQL Connector/Odbc

[iODBC][Driver Manager]Specified driver could not be loadedError message in Excel, if you want to address the database

And now, how it worked for me

iODBC Environment

First of all you have to install the iODBC (3.52.12 or later) environment on the OS X system before your can install the Connector/ODBC. You’ll find the installation packet here:http://www.iodbc.org/dataspace/doc/iodbc/wiki/iodbcWiki/Downloads. Just download and install it. You’ll find the iODBC Administrator in “Programs -> iODBC”

ODBC/Connector mySQL

Before using the iODBC Administrator download an install the ODBC/Connector for MySQL. You’ll find the installation packet here: https://dev.mysql.com/downloads/connector/. Now that the iODBC package is installed, this installation works without the error message “The installation failed”.

Moving the ODBC/Connector

And now a step that makes the use with Excel possible. The Microsoft Office solution under macOS is a Sandboxed application and doesn’t have access to the default installation path of the ODBC/Connector (/usr/local/mysql-connector-odbc …..). You’ll have to move the installation to /Library/ODBC … And you have to do some more modifications. I found the following script (Sam/samsgit on guthub.com) doing this in a perfect way:

#!/bin/bash

 # https://github.com/openlink/iODBC/issues/29
# https://bugs.mysql.com/bug.php?id=89931

 base_src_dir="/usr/local"
mysql_odbc_name=$(ls "$base_src_dir" | grep -m 1 "mysql-connector-odbc")
odbc_dir="/Library/ODBC"

 src="$base_src_dir/$mysql_odbc_name/lib"
dst="$odbc_dir/$mysql_odbc_name/lib"

 echo "creating '$dst'"
sudo mkdir -p "$dst"

 echo "copying '$src' to '$dst'"
sudo cp -af "$src/." "$dst"

  odbc_ini_path="$odbc_dir/odbc.ini"
odbc_ini_bak_path="$odbc_ini_path.bak"

 odbcinst_ini_path="$odbc_dir/odbcinst.ini"
odbcinst_ini_bak_path="$odbcinst_ini_path.bak"

 echo "backing up '$odbc_ini_path' to '$odbc_ini_bak_path'"
sudo cp -f "$odbc_ini_path" "$odbc_ini_bak_path"

 echo "backing up '$odbcinst_ini_path' to '$odbcinst_ini_bak_path'"
sudo cp -f "$odbcinst_ini_path" "$odbcinst_ini_bak_path"

 # https://stackoverflow.com/a/29626460
function replace {
  sudo sed -i '' "s/$(sed 's/[^^]/[&]/g; s/^/\^/g' <<< "$1")/$(sed 's/[&/]/\&/g' <<< "$2")/g" "$3"
}

 ansi_driver=$(ls "$dst" | grep -m 1 "^lib.*a.so$")
unicode_driver=$(ls "$dst" | grep -m 1 "^lib.*w.so$")

 old_ansi_path="$src/$ansi_driver"
new_ansi_path="$dst/$ansi_driver"

 old_unicode_path="$src/$unicode_driver"
new_unicode_path="$dst/$unicode_driver"

 echo "updating '$old_ansi_path' to '$new_ansi_path' in '$odbc_ini_path'"
replace "$old_ansi_path" "$new_ansi_path" "$odbc_ini_path"

 echo "updating '$old_ansi_path' to '$new_ansi_path' in '$odbcinst_ini_path'"
replace "$old_ansi_path" "$new_ansi_path" "$odbcinst_ini_path"

 echo "updating '$old_unicode_path' to '$new_unicode_path' in '$odbc_ini_path'"
replace "$old_unicode_path" "$new_unicode_path" "$odbc_ini_path"

 echo "updating '$old_unicode_path' to '$new_unicode_path' in '$odbcinst_ini_path'"
replace "$old_unicode_path" "$new_unicode_path" "$odbcinst_ini_path"

Just open a terminal window, create a new file with an editor (eg. vi <script name>) and paste the script above. After saving the file make the script executable for your OS (eg. chmod a+x <script name>). Last but not least, run the script (eg. “./<script name>).

Configure the ODBC/Connector

Now you can configure the DSN in the iODBC Administrator. Just add an User DSN:

And it works

Now you can start Excel and navigate to “data” -> “new query” -> “Database” and select your DSN entry 🙂

Update 6/2021

I have reproduced this setup today (June 2021) with the current drivers and Microsoft program versions. Unfortunately, Microsoft has changed the way the ODBC drivers are integrated in the current versions. All tests on the ODBC driver run positively, but unfortunately, it does not work in Excel. 

Microsoft now refers to a paid ODBC plugin from a third party. Apparently they want to push this and have in this course prevented the alternative 🙁

MySQL for Excel 1.3

MySQL for Excel is an Excel Add-In that is installed and accessed from within the MS Excel’s Data tab offering a wizard-like interface arranged in an elegant yet simple way to help users browse MySQL Schemas, Tables, Views and Procedures and perform data operations against them using MS Excel as the vehicle to drive the data in and out MySQL Databases.
Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.

License information can be found in the Installer/LICENSE file.

Installation

  • Prerequisites:
    • Visual Studio 2015 or greater.
    • .NET Framework 4.5.2 (Client or Full Profile).
    • Microsoft Office Excel 2007 or greater, for Microsoft Windows.
    • Visual Studio 2010 Tools for Office SDK (later called Office Developer Tools).
    • WiX Toolset, for building the installer MSI.
    • MSBuild Community Tasks, for building the installer MSI.
  • Open MySQLForExcel.sln or Package.sln in Visual Studio.

Features

MySQL for Excel has been designed to be a simple and friendly tool for data analysts who want to harness the power of MS Excel to play with MySQL data without worrying about the technical details involved to reach the data they want, boosting productivity so they can focus on the data analysis and manipulation.

  • Import Data
    • MySQL for Excel makes the task of getting MySQL data into Excel a very easy one; there are no intermediate CSV files required, only a couple of clicks and data will be imported to Excel. MySQL for Excel supports importing data from tables, views and stored procedures.
  • Export Data
    • MySQL for Excel allows users to create a new MySQL table from selected Excel data; data types are automatically recognized and defaulted for the new table and column names can be created from the first row of data, speeding up the process and making it simple for non-technical users.
  • Append Data
    • MySQL for Excel lets users save selected Excel data in existing tables; it will automatically attempt to map the columns of the selection with the ones in the MySQL table by column name or by data type, users can then review the mapping, manually change it and store it for later use. Like the Export Data feature, appending data into an existing table is very easy.
  • Edit Data
    • MySQL for Excel now provides a way to edit a MySQL table’s data directly within Excel using a new worksheet as a canvas to update existing data, insert new rows and delete existing ones in a very friendly and intuitive way. Changes are pushed back to the MySQL Server as a transaction batch with the click of a button, or can be pushed as soon as they are done with no further clicks if users prefer it. This is a powerful feature since Excel is a natural user interface to operate with data, and these changes can be reflected in the database immediately.

Documentation

For further information about MySQL or additional documentation, see:

  • http://www.mysql.com
  • http://dev.mysql.com/doc/mysql-for-excel/en/

I have numerous Excel workbooks that I use to keep track of HR-related information. In order to minimize data duplication, I have consolidated these records into as few files as possible, but some of the core information such as Names, Employee ID numbers, and Job Titles are necessarily duplicated between files.

Wouldn’t it be great if the main information could just be updated in one place and then propagate across various systems and files? I’m working on porting all of my Excel files into a web-based system, but it’s really a side-project, so in the meantime I wanted a solution to reduce this duplication, and I think I may have found a realistic solution.

Why not keep the main employee information, which is currently duplicated across several Excel files, in a MySQL database and then link this into each of my Excel workbooks so that any update to these data will automatically update in all the files. As an added bonus, this database could later form the core of the web-based system, allowing me to implement features incrementally.

I already have a MySQL server on the local network that synchronizes attendance data from our fingerprint attendance device. So I’m going to use the employees table in that database as the source for my Excel files to get their employee data.

Here are my notes of how I got it working on Excel 16.32 running on Mac OS 10.15.1 connecting via LAN to MySQL 5.7.28 on Ubuntu 18.04 LTS.

Setup

On MySQL server

By default, MySQL will only accept connections from the local machine, and the default recommended privileges for a new user also include @localhost.

Side note:
You can check what ports and addresses your MySQL is currently listening on with:

$ netstat -tulpen

To make sure you will be able to connect (leaving any firewall configuration changes up to you):

1. Change the default bind-address:

$ sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

On some versions you may need to use /etc/mysql/conf.d/mysql.cnf or /etc/mysql/my.cnf.

Different versions appear to work differently as well, so either comment out the existing bind-address:

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
# bind-address = 127.0.0.1

or change the existing bind-address line to:

bind-address = 0.0.0.0

Then restart mysqld

$ sudo /etc/init.d/mysql restart

2. Add a new user with the @ set to your computer’s IP address if you have a static IP, or else use a wildcard for computers on your local subnet:

GRANT ALL PRIVILEGES ON *.* to 'remoteuser’@’10.1.1.%' IDENTIFIED BY 'remoteuserspassword' WITH GRANT OPTION;

Obviously, adjust as necessary, and if copying and pasting make sure to double-check that quote marks and dashes etc haven’t been autocorrected to pretty versions.

On MacOS

  1. Install ODBC Manager (Freeware alternative to ODBC Administrator)
    http://www.odbcmanager.net/
  2. Install the MySQL connector
    https://dev.mysql.com/downloads/connector/odbc/
  3. Move the installed connector from local to global library
    https://stackoverflow.com/questions/52896893/macos-connector-mysql-odbc-driver-could-not-be-loaded-in-excel-for-mac-2016 quoted below:

    I was able to connect to MySQL with Microsoft Excel Version 16.19 by making the following adjustments:
    1. I copied the driver’s whole directory /mysql-connector-odbc-8.0.12-macos10.13-x86-64bit to /Library/ODBC (why? see https://bugs.mysql.com/bug.php?id=89931, and Is there a way to get ADODB to work with Excel for Mac 2011?) ; basically the reason for that is the driver gets downloaded to /usr/local and Excel, being sandboxed, cannot access that location.
    2. Updated the file odbc.ini, also located in /Library/ODBC, with the driver’s new location.

  4. Run ODBC manager and add your remote MySQL database with options SERVER and PORT set appropriately (see the default entries for syntax). Click on Test to make sure the connection works.

Making the Connection

Open Excel and navigate to the Data tab, select New Database Query, From Database.

In the iODBC Data Source Chooser window that opens, select the new ODBC Data Source you just added in ODBC manager and click OK. Enter your new MySQL username and password when prompted.

Enter a single-line query and click on Run. If no errors occur (and reasonable results appear in the preview pane) then send the results back to Excel by clicking on Return Data. Choose whether to add the results to the current worksheet, a new worksheet, or a pivot table. You can also click on Properties to choose when and how frequently the data will be refreshed. Note that if the database is on an intranet server and you open the Excel sheet from home, for example, the file will still open but it will just use the version of the data from when it was last opened.

This blog post shows you how to configure Excel 2011 on Mac OS X to query a MySQL database natively installed on the same Mac. If you need installation instructions for the MySQL database natively on Mac OS X, use this post. The configuration is only required the first time and then you may reuse the connection later.

Before you can begin these steps inside Excel 2011, you need to download and install OpenLink Software’s ODBC Driver. I’ve posted instructions in this other blog page because all the screen shots make page loading a problem. You open a new Workbook and click on the Data tab. Then, on the Database icon in the Data ribbon. It lets you import data from the database.

The configuration steps are as follows:

  1. This first step prompt you to install Rosetta which allows native Power PC applications to run your Intel-based Mac OS X. It will eventually no longer be supported with the release of Lion (at least that’s the rumor at the time of writing). Click the Install button to get this working.

Configure Excel 2011 to query MySQL #1

  1. The install took a minute on my Mac Pro, so I figured you should see the progress bar in case it takes a half minute or so.

Configure Excel 2011 to query MySQL #2

  1. After the completion, you now configure a Data Source Name. This type of configuration is provided for by components on the Windows OS (see this post for an example), which don’t exist on Mac OS X. It appears that Microsoft didn’t want to provide those components, which are a dependency for Excel 2011, and that’s why you need OpenLink Software, specifically the iODBC Data Source Connector. You should note that it looks virtually the same as the Windows OS component. Click the Add button to proceed.

Configure Excel 2011 to query MySQL #3

  1. The next screen lets you choose a driver from those installed on the Mac OS X system. If you went to the bother to install the free MySQL Connector/ODBC (instructions here), it won’t work because the Microsoft Component requires Rosetta to work. It appears that Microsoft Query isn’t a native Intel-port but rather a Power PC port. Choose one of the OpenLinnk drivers and click the Finish button to continue.

Configure Excel 2011 to query MySQL #4

  1. The next step requires that you configure the Data Source Name (DSN), provide a hostname and listener port for MySQL (the default port is 3306). After you enter these values, click the Connection tab to the right of the Data Source tab in the dialog box.

Configure Excel 2011 to query MySQL #5

  1. This step requires that you set the user name, password, and database. The ability to pick the database in the iODBC Data Source Connector is the result of the MySQL Lite tool. It requires that you’ve configured the database first. After entering the data, click the Options tab in the dialog to set the next set of values.

Configure Excel 2011 to query MySQL #6

  1. This step doesn’t initially let you do much but afterward you can set the character set. Click the Preference tab to proceed with the configuration.

Configure Excel 2011 to query MySQL #7

  1. There’s nothing you need do here, but I’d suggest in a real situation that you click the Always include VIEWS in table list check box before you click the Finish button.

Configure Excel 2011 to query MySQL #8

  1. The Data Source Name setup is complete, the next screen lets you launch a connection to the MySQL database. Click the OK button to complete the configuration.

Configure Excel 2011 to query MySQL #9

  1. At this point, you repeat the Step #1. It launches the iODBC Data Source Chooser dialog. Click the Data Source Name and then the Test button.

Configure Excel 2011 to query MySQL #10

  1. The test launches a dialog to test the connection, as shown below. Enter the Password in the dialog.

Configure Excel 2011 to query MySQL #11

  1. If you’ve configured everything correctly, you’ll see the following confirmation dialog. Click the OK button.
  2. Configure Excel 2011 to query MySQL #12

Hope this helps you if you’re looking to connect Excel 2011 to query MySQL.

Содержание

  1. MacLochlainns Weblog
  2. Excel 2011 Query MySQL
  3. Using ODBC driver on MacOS and Excel to access a mySQL database
  4. MacLochlainns Weblog
  5. Excel 2011 MySQL Config
  6. 4 Responses to ‘Excel 2011 MySQL Config’

MacLochlainns Weblog

Michael McLaughlin’s Technical Blog

Excel 2011 Query MySQL

I finally got around to finishing my testing of Excel 2011 querying MySQL. That meant installing and configuring Excel 2011 and MySQL 5.5.9 on Mac OS X (Snow Leopard). While installing Microsoft Office is pretty trivial, installing and configuring MySQL wasn’t. You can read about installing and configuring MySQL here. A quick test after this, led me to discover that you still need a third party ODBC, as covered in this earlier blog. You should take note that Microsoft’s future direction adopts Oracle ODBC, like the approach they’ve chosen with MySQL’s ODBC driver.

I downloaded and installed one of third party ODBC tool sets. I opted for OpenLink Software’s ODBC Driver. Instructions for the install with screen shots are in this blog page. The only downside of this was the discovery that Microsoft’s solution requires Rosetta, like Excel 2008. Rosetta enables Power PC application to run on Intel-based Mac OS X.

Launching the Database icon from Excel 2011, I configured the Data Source Name, which you can find here with screen shots. After you configure the Data Source Name, restarting Excel 2011 is the best choice because otherwise you may see several non-fatal errors.

The following screen shots show you how to establish a connection between Excel 2011 and MySQL, and how to query data from the MySQL database:

  1. After you click the Database icon, you see the following dialog. Select a Data Source Name and click the OK button to begin a query.

  1. The OpenLink MySQL Lite Login screen requires the user name and password. Click the Connect button to launch the Microsoft Query, which appears to be a native Power PC application that requires Rosetta to run it

  1. Microsoft Query appears to be a native Power PC application that requires Rosetta to run it. If you want to enter a query, click the SQL View button.

  1. Having clicked the SQL View button you now have a work area where you can enter a standard SQL SELECT statement, like the one below. Then, you click the Return Data button.

  1. This dialog lets you select where you want to put the return result set from the query. The default is the absolute cell reference of the top and left most cell, $A$1 . Click the OK button to query and load the data into the worksheet.

  1. Now you can see the data in the worksheet. The only problem is the extraneous characters returned into the column headers of the table. While tedious, they’re easy to fix. The following illustrates the downloaded result set from the previous query:

  1. If you perform a query with a join operation, the column names are never displayed whether you provide aliases to the query or not. It means you have to convert the table to a range, remove the false headers, and recreate the table. This appears to be a limitation of Microsoft Query and unlike the behavior in Excel 2010 on Windows. Perhaps it’s all wrapped up in the emulation provided by Rosetta but I couldn’t find any information about what’s happening. That leaves me with pure speculation, which I never like. If you find the reason, post a comment with a link because everyone would benefit.

As always, I hope this helps those who want to work only in the Mac OS X environment. The risk is Rosetta because it will go away, the only question is when and whether the vendors will fix their dependency first or not. The problem with this solution is that Microsoft Query doesn’t return any tables when it appears that it should.

Источник

Using ODBC driver on MacOS and Excel to access a mySQL database

Ever tried to access a mySQL database within Excel on macOS using the ODBC driver (64bit)? – I tried and failed. Here is my way out of the mess.

Using a Windows environment it is so pretty simple: Download ODBC driver for Windows from the mySQL Webpage, install it, open the system control -> ODBC configuration, add a DSN using input fields, test it. Next start Excel, external datasource, select DSN and voila: full access to the database.

I’ll spare you all the details of failure and just list a few of the error messages on the way to success:

The installation failed. The Installer encountered an error the caused the installation to fail. Contact the software manufacturer for assistance.

Error message if you want to install the MySQL Connector/Odbc

[iODBC][Driver Manager]Specified driver could not be loaded

Error message in Excel, if you want to address the database

And now, how it worked for me

iODBC Environment

First of all you have to install the iODBC (3.52.12 or later) environment on the OS X system before your can install the Connector/ODBC. You’ll find the installation packet here:http://www.iodbc.org/dataspace/doc/iodbc/wiki/iodbcWiki/Downloads. Just download and install it. You’ll find the iODBC Administrator in “Programs -> iODBC”

ODBC/Connector mySQL

Before using the iODBC Administrator download an install the ODBC/Connector for MySQL. You’ll find the installation packet here: https://dev.mysql.com/downloads/connector/. Now that the iODBC package is installed, this installation works without the error message “The installation failed”.

Moving the ODBC/Connector

And now a step that makes the use with Excel possible. The Microsoft Office solution under macOS is a Sandboxed application and doesn’t have access to the default installation path of the ODBC/Connector (/usr/local/mysql-connector-odbc …..). You’ll have to move the installation to /Library/ODBC … And you have to do some more modifications. I found the following script (Sam/samsgit on guthub.com) doing this in a perfect way:

Just open a terminal window, create a new file with an editor (eg. vi

Источник

MacLochlainns Weblog

Michael McLaughlin’s Technical Blog

Excel 2011 MySQL Config

This blog post shows you how to configure Excel 2011 on Mac OS X to query a MySQL database natively installed on the same Mac. If you need installation instructions for the MySQL database natively on Mac OS X, use this post. The configuration is only required the first time and then you may reuse the connection later.

Before you can begin these steps inside Excel 2011, you need to download and install OpenLink Software’s ODBC Driver. I’ve posted instructions in this other blog page because all the screen shots make page loading a problem. You open a new Workbook and click on the Data tab. Then, on the Database icon in the Data ribbon. It lets you import data from the database.

The configuration steps are as follows:

  1. This first step prompt you to install Rosetta which allows native Power PC applications to run your Intel-based Mac OS X. It will eventually no longer be supported with the release of Lion (at least that’s the rumor at the time of writing). Click the Install button to get this working.

  1. The install took a minute on my Mac Pro, so I figured you should see the progress bar in case it takes a half minute or so.

  1. After the completion, you now configure a Data Source Name. This type of configuration is provided for by components on the Windows OS (see this post for an example), which don’t exist on Mac OS X. It appears that Microsoft didn’t want to provide those components, which are a dependency for Excel 2011, and that’s why you need OpenLink Software, specifically the iODBC Data Source Connector. You should note that it looks virtually the same as the Windows OS component. Click the Add button to proceed.

  1. The next screen lets you choose a driver from those installed on the Mac OS X system. If you went to the bother to install the free MySQL Connector/ODBC (instructions here), it won’t work because the Microsoft Component requires Rosetta to work. It appears that Microsoft Query isn’t a native Intel-port but rather a Power PC port. Choose one of the OpenLinnk drivers and click the Finish button to continue.

  1. The next step requires that you configure the Data Source Name (DSN), provide a hostname and listener port for MySQL (the default port is 3306). After you enter these values, click the Connection tab to the right of the Data Source tab in the dialog box.

  1. This step requires that you set the user name, password, and database. The ability to pick the database in the iODBC Data Source Connector is the result of the MySQL Lite tool. It requires that you’ve configured the database first. After entering the data, click the Options tab in the dialog to set the next set of values.

  1. This step doesn’t initially let you do much but afterward you can set the character set. Click the Preference tab to proceed with the configuration.

  1. There’s nothing you need do here, but I’d suggest in a real situation that you click the Always include VIEWS in table list check box before you click the Finish button.

  1. The Data Source Name setup is complete, the next screen lets you launch a connection to the MySQL database. Click the OK button to complete the configuration.

  1. At this point, you repeat the Step #1. It launches the iODBC Data Source Chooser dialog. Click the Data Source Name and then the Test button.

  1. The test launches a dialog to test the connection, as shown below. Enter the Password in the dialog.

    If you’ve configured everything correctly, you’ll see the following confirmation dialog. Click the OK button.

Hope this helps you if you’re looking to connect Excel 2011 to query MySQL.

Written by maclochlainn

February 27th, 2011 at 12:36 am

Posted in Uncategorized

4 Responses to ‘Excel 2011 MySQL Config’

Subscribe to comments with RSS or TrackBack to ‘Excel 2011 MySQL Config’.

Источник

Понравилась статья? Поделить с друзьями:
  • Mysql for excel export data
  • Mysql export to excel file
  • Mysql connector для excel
  • Myriad pro шрифт скачать word
  • My worst things in the word