Sunday, 31 January 2016

Installing mysqlworkbench and mysql utils in MacOSX Yosemite





Installing MySQL, mysqlworkbench and mysql-utils in Yosemite


For installing things like *nix in MacOSX I use homebrew.

Homebrew is fantastic for installing tar.gz files in textual way, but there are some packages that are only in .dmg format and you need to use a package manager that knows how to install this GUI based installers. This package manager is homebrew cask (caskroom project)

First you need to install mysql

$ brew install mysql
$ mysql.server start 
# and optionaly make it more secure
$ mysql_secure_installation


Then you need to 'tap' the cask project and then get your 'cask' before 'pouring' it.


$ brew tap caskroom/cask
# optional
$ brew install homebrew/completions/brew-cask-completion

## install workbench and utils

$ brew cask install mysqlworkbench
# mysqlworkbench staged at '/opt/homebrew-cask/Caskroom/mysqlworkbench/6.3.6'
# Symlinking App 'MySQLWorkbench.app' to '/Users/pmg/Applications/MySQLWorkbench.app'

$ brew cask install mysql-utilities
# mysql-utilities staged at '/opt/homebrew-cask/Caskroom/mysql-utilities/1.5.6'


Note that workbench is symlinked to your home apps not the main Application folder


~/Applications/MySQLWorkbench.app

Launch it and you will get this window with the MySQL Utils icon at the top right


When you click in the MySQL Utilities.... OPS!! it does not work!

MySQL Utils launch a console and the error message is

$ mysqluc -e "help utilities"
ERROR: The MySQL Connector/Python module was not found. MySQL Utilities requires the connector to be installed. Please check your paths or download and install the Connector/Python from http://dev.mysql.com.


OK, lets find the connector googleing it. And find it


[EDIT] I have just missed that the mysql-connector-python is also in cask and you can install with `brew cask install mysql-connector-python` BUT IT DID NOT WORK FOR ME

$ brew search mysql
automysqlbackup                    mysql                             mysql++                            mysql-cluster                      mysql-connector-c                  mysql-connector-c++                mysql-sandbox                      mysql-search-replace               mysqltuner                       
homebrew/php/php53-mysqlnd_ms                       homebrew/php/php55-mysqlnd_ms                       homebrew/versions/mysql51                           homebrew/versions/mysql56                           Caskroom/cask/mysql-utilities                       Caskroom/cask/navicat-for-mysql                   
homebrew/php/php54-mysqlnd_ms                       homebrew/php/php56-mysqlnd_ms                       homebrew/versions/mysql55                           Caskroom/cask/mysql-connector-python                Caskroom/cask/mysqlworkbench                      



$ brew cask install mysql-connector-python
Error: No available Cask for mysql-connector-python
Error: nothing to install


at http://dev.mysql.com/downloads/connector/python/ but instead of selecting Mac choose "platform independent"


choose download and and then copy the link from "no thanks, just start download"



Go back to your shell and download it (you can do it in the mysql-utils dir just to have all together)

$ cd /opt/homebrew-cask/Caskroom/mysql-utilities/
$ wget http://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-2.1.3.tar.gz
$ tar -zxvf mysql-connector-python-2.1.3.tar.gz
$ cd mysql-connector-python-2.1.3/

# install for both python
$ sudo python ./setup.py install
$ sudo python3 ./setup.py install
</ pre>

Now when you click in the MySQL-Utils you have a working connection and you see this in the launched terminal



P.S.

I have tried to install the connector from python using pip but it did not work due a problem with ConfigParser. I did not investigate it further because I have already a working solution.


        MacBook-Pro:[~]
        $ pip3 install MySQL-python
        Collecting MySQL-python
          Downloading MySQL-python-1.2.5.zip (108kB)
            Complete output from command python setup.py egg_info:
            Traceback (most recent call last):
              File "<string>", line 20, in <module>
              File "/private/var/folders/m0/spbgfzvd17jdfqgx90w1_hx40000gn/T/pip-build-0nif_qmi/MySQL-python/setup.py", line 13, in <module>
                from setup_posix import get_config
              File "/private/var/folders/m0/spbgfzvd17jdfqgx90w1_hx40000gn/T/pip-build-0nif_qmi/MySQL-python/setup_posix.py", line 2, in <module>
                from ConfigParser import SafeConfigParser
            ImportError: No module named 'ConfigParser'

            ----------------------------------------
        Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/m0/spbgfzvd17jdfqgx90w1_hx40000gn/T/pip-build-0nif_qmi/MySQL-python
        You are using pip version 7.1.2, however version 8.0.2 is available.
        You should consider upgrading via the 'pip install --upgrade pip' command.
       
        MacBook-Pro:[~]
        $ pip3 install ConfigParser
        Collecting ConfigParser
          Downloading configparser-3.3.0r2.tar.gz
            Complete output from command python setup.py egg_info:
            Traceback (most recent call last):
              File "<string>", line 3, in <module>
              File "/usr/local/lib/python3.5/site-packages/setuptools/__init__.py", line 5, in <module>
                import distutils.core
              File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/core.py", line 18, in <module>
                from distutils.config import PyPIRCCommand
              File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/config.py", line 7, in <module>
                from configparser import ConfigParser
              File "/private/var/folders/m0/spbgfzvd17jdfqgx90w1_hx40000gn/T/pip-build-0ouo8j8z/ConfigParser/configparser.py", line 397
                _KEYCRE = re.compile(ur"%\(([^)]+)\)s")
                                                     ^
            SyntaxError: invalid syntax


            ----------------------------------------