<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Arshad Hossain Antu</title>
    <description>The latest articles on DEV Community by Arshad Hossain Antu (@arshad12).</description>
    <link>https://dev.to/arshad12</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F546969%2Fd229b7d9-aa35-4c39-b33c-932efa0fe3b5.jpeg</url>
      <title>DEV Community: Arshad Hossain Antu</title>
      <link>https://dev.to/arshad12</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arshad12"/>
    <language>en</language>
    <item>
      <title>A summary of MySQL iODBC MacOS Installation</title>
      <dc:creator>Arshad Hossain Antu</dc:creator>
      <pubDate>Sat, 16 Jan 2021 19:33:15 +0000</pubDate>
      <link>https://dev.to/arshad12/a-summary-of-mysql-iodbc-for-macos-installation-3eh8</link>
      <guid>https://dev.to/arshad12/a-summary-of-mysql-iodbc-for-macos-installation-3eh8</guid>
      <description>&lt;p&gt;This is a summary mainly for myself &lt;em&gt;(to find later if lost or need a newly mac setup)&lt;/em&gt; and also to anyone who want to connect to a mysql database and run queries in Microsoft Excel. More specifically described and main author and content created by &lt;strong&gt;Stefan Schaffner&lt;/strong&gt; without whom I would not be able to get this working. &lt;a href="https://stefan-schaffner.de/posts/using-odbc-driver-on-macos-and-excel-to-access-a-mysql-database/"&gt;(Content Link)&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download and install the latest stable version of iODBC for MacOS. You can't go wrong with the DMG file. &lt;a href="http://www.iodbc.org/dataspace/doc/iodbc/wiki/iodbcWiki/Downloads"&gt;http://www.iodbc.org/dataspace/doc/iodbc/wiki/iodbcWiki/Downloads&lt;/a&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ozwh4pZH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/iew41l1tqwl2ni4uyb61.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Download and install the latest version of ODBC MySQL connector and same as before DMG file works fine. &lt;a href="https://dev.mysql.com/downloads/connector/odbc/"&gt;https://dev.mysql.com/downloads/connector/odbc/&lt;/a&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k7ykxnFl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xzfcww4s1r9phpq6od3d.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Now for the main part, as Microsoft office runs in a sandbox in MacOS it can't get access to any ODBC install paths and that's a real pain for us all. What we need is to move the ODBC installation to  /library which was originally in /usr/local. So a simple script made by &lt;strong&gt;samsgit's&lt;/strong&gt; &lt;a href="https://github.com/openlink/iODBC/issues/29#issuecomment-426790551"&gt;Github Comment&lt;/a&gt; works like a charm.
So what I did,
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo nano odbc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy and paste the whole script. &lt;strong&gt;Created by samsgit&lt;/strong&gt;,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/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/[^^]/[&amp;amp;]/g; s/\^/\\^/g' &amp;lt;&amp;lt;&amp;lt; "$1")/$(sed 's/[&amp;amp;/\]/\\&amp;amp;/g' &amp;lt;&amp;lt;&amp;lt; "$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"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the file and run the following command to give executable permission,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo chmod a+x odbc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now just let the magic happen by running the script,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ./odbc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Finally, just open your iODBC Administrator from applications.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vmIeM2JG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hvjh0k44klmpwn86nkjc.png" alt="Alt Text"&gt;
Now &lt;code&gt;Add&lt;/code&gt; a new &lt;code&gt;User DSN&lt;/code&gt; &amp;gt; Select a Driver example:&lt;code&gt;MySQL ODBC 8.0 Unicode Driver&lt;/code&gt; &amp;gt; Give a name and set keys for &lt;code&gt;user&lt;/code&gt;, &lt;code&gt;password&lt;/code&gt;, &lt;code&gt;server&lt;/code&gt;, &lt;code&gt;database&lt;/code&gt; and &lt;code&gt;port&lt;/code&gt;.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U_5Blvzi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gge8lh1drldvyvpn0z52.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Now we are good to go. &lt;code&gt;Open excel&lt;/code&gt; &amp;gt; &lt;code&gt;Data&lt;/code&gt; &amp;gt; &lt;code&gt;New Database Query&lt;/code&gt; &amp;gt; Select your saved &lt;code&gt;DSN&lt;/code&gt;.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gRiGpsFa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fn4yp49miihkjkj641gw.png" alt="Alt Text"&gt;
Now you just write your query and enjoy your report in you Microsoft Excel on MacOS.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Reference:&lt;br&gt;
Content instruction followed from &lt;strong&gt;Stefan Schaffner&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://stefan-schaffner.de/posts/using-odbc-driver-on-macos-and-excel-to-access-a-mysql-database/"&gt;(Content Link)&lt;/a&gt;&lt;/p&gt;

</description>
      <category>macos</category>
      <category>mysql</category>
      <category>odbc</category>
      <category>excel</category>
    </item>
  </channel>
</rss>
