Setting up Vim SQL Workbench on MacOS

Nov. 16, 2019

This serves as my guide in case I would have to do it again, like when a clean OS reinstall is needed. This guide is for MacOS Mojave.

Here are the apps I installed:

  • MacVim v161 using dmg installer
  • SQLWorkBenchJ build 124 using dmg installer
  • MySQL 5.6 using brew
  • vim-sql-workbench using git clone

After following the official vim-sql-workbench documentation, I ended up with these lines in my .vimrc:

let g:sw_config_dir = '/Users/username/.sqlworkbench/'
let g:sw_exe = '/Applications/SQLWorkbenchJ.app/Contents/Java/sqlwbconsole.sh'
let g:sw_cache = '/Users/username/.cache/sw/'

The 2nd line is a result of following this guide here. In summary, I downloaded Workbench-Build124.zip, unzipped it, then copied the file sqlwbconsole.sh to that directory as above.

After copying sqlwbconsole.sh into its final directory, run:

chmod +x sqlwbconsole.sh.

Edit this file by modifying line 4 from:
SCRIPT_PATH="$(dirname "$(readlink -f "$0")")"
to
SCRIPT_PATH="$(dirname "$(greadlink -f "$0")")"

Install coreutils as mentioned here using command "brew install coreutils".

To connect, download the latest jdbc connector, then execute this in the buffer:

For MySQL:
WbConnect -url=jdbc:mysql://localhost:3306/mysql -driverJar=/Users/username/Documents/Apps/mysql-connector-java-8.0.18.jar -username=username -password=;

For Oracle:
WbConnect -url=jdbc:oracle:thin:@//localhost:1521/myschema -username=username -password=;

TODO:
I'm still getting this error every time I connect to a MySQL database:

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.


by Noel Puru
I'm a Python web developer by profession and the author of Noel Codes and Ancient View. I like coding and reading books, specially the Bible.